ios – – [WelcomeUI _setViewDelegate:]:无法识别的选择器发送到实例0xc061110

这是错误
2013-09-30 17:59:23.212 The Solver[422:a0b] -[WelcomeUI _setViewDelegate:]: unrecognized selector sent to instance 0xc061110
2013-09-30 17:59:23.222 The Solver[422:a0b] *** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: '-[WelcomeUI _setViewDelegate:]: unrecognized selector sent to instance 0xc061110'
*** First throw call stack:
(
    0   CoreFoundation                      0x023605e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014be8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x023fd903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x0235090b ___forwarding___ + 1019
    4   CoreFoundation                      0x023504ee _CF_forwarding_prep_0 + 14
    5   UIKit                               0x0013d55c +[UIViewController setViewController:forView:] + 40
    6   UIKit                               0x00137fb1 -[UIViewController setView:] + 511
    7   Foundation                          0x00edef68 _NSSetUsingkeyvalueSetter + 133
    8   Foundation                          0x00ede493 -[NSObject(NSkeyvalueCoding) setValue:forKey:] + 267
    9   Foundation                          0x00f4094a -[NSObject(NSkeyvalueCoding) setValue:forKeyPath:] + 412
    10  UIKit                               0x002c5cd5 -[UIRuntimeOutletConnection connect] + 106
    11  libobjc.A.dylib                     0x014d07d2 -[NSObject performSelector:] + 62
    12  CoreFoundation                      0x0235bb6a -[NSArray makeObjectsPerformSelector:] + 314
    13  UIKit                               0x002c482e -[UINib instantiateWithOwner:options:] + 1417
    14  UIKit                               0x00136c95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    15  UIKit                               0x0013743d -[UIViewController loadView] + 302
    16  UIKit                               0x0013773e -[UIViewController loadViewIfrequired] + 78
    17  UIKit                               0x00137c44 -[UIViewController view] + 35
    18  UIKit                               0x000605ad -[UIWindow addRootViewControllerViewIfPossible] + 66
    19  UIKit                               0x00060947 -[UIWindow _setHidden:forced:] + 312
    20  UIKit                               0x00060bdd -[UIWindow _orderFrontWithoutMakingKey] + 49
    21  UIKit                               0x0006b44a -[UIWindow makeKeyAndVisible] + 65
    22  UIKit                               0x0001e8e0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
    23  UIKit                               0x00022fb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
    24  UIKit                               0x0003742c -[UIApplication handleEvent:withNewEvent:] + 3447
    25  UIKit                               0x00037999 -[UIApplication sendEvent:] + 85
    26  UIKit                               0x00024c35 _UIApplicationHandleEvent + 736
    27  GraphicsServices                    0x022be2eb _PurpleEventCallback + 776
    28  GraphicsServices                    0x022bddf6 PurpleEventCallback + 46
    29  CoreFoundation                      0x022dbdd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    30  CoreFoundation                      0x022dbb0b __CFRunLoopDoSource1 + 523
    31  CoreFoundation                      0x023067ec __CFRunLoopRun + 2156
    32  CoreFoundation                      0x02305b33 CFRunLoopRunSpecific + 467
    33  CoreFoundation                      0x0230594b CFRunLoopRunInMode + 123
    34  UIKit                               0x000226ed -[UIApplication _run] + 840
    35  UIKit                               0x0002494b UIApplicationMain + 1225
    36  The Solver                          0x0000274d main + 141
    37  libdyld.dylib                       0x059a4725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

这是代码

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc,char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc,argv,nil,NsstringFromClass([AppDelegate class]));
    }
}

这是什么标记

返回UIApplicationMain(argc,NsstringFromClass([AppDelegate class]));

请说明我做错了什么

解决方法

正如我们在评论中讨论的,问题在于您的NIB配置.视图控制器的根视图正在使用自定义类WelcomeUI,它不是UIView的子类.当试图设置其视图时,视图控制器加载了成功初始化了WelcomeUI实例的NIB,但是当它尝试执行选择器_setViewDelegate时会崩溃:因为它不是视图.

解决此问题,您只需要进入Interface Builder,展开视图控制器以选择视图(在侧栏中可能显示为“WelcomeUI”),打开身份检查器并删除自定义类.

由于您打算设置视图控制器的自定义类,您可以在左侧栏中选择视图控制器本身,并将其自定义类设置为“WelcomeUI”.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...