2013-09-30 16 views
15

以下是錯誤:- [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])); 
    } 
} 

這裏是下垂:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

請解釋我做錯了什麼。

+3

看起來你使用的是NIB,你試圖爲視圖控制器的頂層視圖('WelcomeUI')設置一個自定義類,並且'WelcomeUI'不是'UIView'的子類。 –

+0

我該如何解決這個問題? –

+0

進入IB,選擇您的視圖控制器,選擇頂層視圖,在右側將「WelcomeUI」中的「Custom Class」更改爲您的意思。 –

回答

31

正如我們在評論中所討論的,問題在於您的NIB配置。視圖控制器的根視圖使用自定義類WelcomeUI,它不是UIView的子類。當試圖設置它的視圖時,視圖控制器加載了成功初始化WelcomeUI實例的NIB,但在嘗試執行選擇器_setViewDelegate:時崩潰,因爲它不是視圖。

要解決這個問題,你只需要進入Interface Builder中,展開您的視圖控制器來選擇視圖(可能在側邊欄顯示爲「WelcomeUI」),打開身份檢查和刪除自定義類。

View of the above code in Xcode

既然你已經打算設置的自定義類視圖控制器,你可以選擇在左側欄視圖控制器本身並設置其自定義類「WelcomeUI」。

+0

這是那些可能會讓我失望幾天的錯誤之一。故事板相關的錯誤應該提供更多的人類可讀的消息/日誌= \ – ACLima

相關問題