2011-07-29 72 views
0

這是我得到的錯誤,當我嘗試和模態顯示我的應用程序內的視圖控制器:似乎無法擺脫鍵值順應編碼錯誤的

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<KVPasscodeViewController 0x8b815a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key instructionLabel.' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x011185a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x0126c313 objc_exception_throw + 44 
    2 CoreFoundation      0x011184e1 -[NSException raise] + 17 
    3 Foundation       0x00aea677 _NSSetUsingKeyValueSetter + 135 
    4 Foundation       0x00aea5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285 
    5 UIKit        0x0056630c -[UIRuntimeOutletConnection connect] + 112 
    6 CoreFoundation      0x0108e8cf -[NSArray makeObjectsPerformSelector:] + 239 
    7 UIKit        0x00564d23 -[UINib instantiateWithOwner:options:] + 1041 
    8 UIKit        0x00566ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 
    9 UIKit        0x0041c628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70 
    10 UIKit        0x0041a134 -[UIViewController loadView] + 120 
    11 UIKit        0x0041a00e -[UIViewController view] + 56 
    12 UIKit        0x00418482 -[UIViewController contentScrollView] + 42 
    13 UIKit        0x00428f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48 
    14 UIKit        0x00427555 -[UINavigationController _layoutViewController:] + 43 
    15 UIKit        0x00428870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524 
    16 UIKit        0x0042332a -[UINavigationController _startDeferredTransitionIfNeeded] + 266 
    17 UIKit        0x0053e2e9 -[UILayoutContainerView layoutSubviews] + 226 
    18 QuartzCore       0x002a6a5a -[CALayer layoutSublayers] + 181 
    19 QuartzCore       0x002a8ddc CALayerLayoutIfNeeded + 220 
    20 QuartzCore       0x002a8ed0 -[CALayer layoutIfNeeded] + 111 
    21 UIKit        0x0041b58a -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] + 587 
    22 UIKit        0x0039255f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 4347 
    23 UIKit        0x00619619 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1381 
    24 UIKit        0x0041e65d -[UIViewController presentModalViewController:withTransition:] + 3478 
    25 DearMe        0x00011ca1 -[NotificationViewController addPasscode] + 273 
    26 UIKit        0x0036a4fd -[UIApplication sendAction:to:from:forEvent:] + 119 
    27 UIKit        0x003fa799 -[UIControl sendAction:to:forEvent:] + 67 
    28 UIKit        0x003fcc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
    29 UIKit        0x003fb7d8 -[UIControl touchesEnded:withEvent:] + 458 
    30 UIKit        0x0038eded -[UIWindow _sendTouchesForEvent:] + 567 
    31 UIKit        0x0036fc37 -[UIApplication sendEvent:] + 447 
    32 UIKit        0x00374f2e _UIApplicationHandleEvent + 7576 
    33 GraphicsServices     0x015f2992 PurpleEventCallback + 1550 
    34 CoreFoundation      0x010f9944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    35 CoreFoundation      0x01059cf7 __CFRunLoopDoSource1 + 215 
    36 CoreFoundation      0x01056f83 __CFRunLoopRun + 979 
    37 CoreFoundation      0x01056840 CFRunLoopRunSpecific + 208 
    38 CoreFoundation      0x01056761 CFRunLoopRunInMode + 97 
    39 GraphicsServices     0x015f11c4 GSEventRunModal + 217 
    40 GraphicsServices     0x015f1289 GSEventRun + 115 
    41 UIKit        0x00378c93 UIApplicationMain + 1160 
    42 DearMe        0x000029df main + 127 
    43 DearMe        0x00002955 start + 53 
    44 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 

爲什麼任何想法可能會造成?

編輯:其中提供了錯誤的代碼:

KVPasscodeViewController *passcodeController = [[KVPasscodeViewController alloc] init]; 
    passcodeController.delegate = self; 
    UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeController]; 
    [self.navigationController presentModalViewController:passcodeNavigationController animated:YES]; 
    [passcodeNavigationController release]; 
    [passcodeController release]; 

回答

1

因爲你有一個出口在XIB該視圖控制器在「instructionLabel」指向這引起。

+0

視圖控制器確實有一個.xib文件,但我刪除它 - 它不再使用.xib文件。但它似乎認爲它確實如此。我乾淨了,但這並沒有阻止這個問題。 – Andrew

+0

你可以添加你用來顯示VC的代碼嗎?跟蹤正在加載一個NIB。 –

+0

當然。我編輯過它。 – Andrew

1

您有一個.xib文件最有可能指向不存在的標籤。如果在Interface Builder中添加UILabel,通常會發生這種情況,請將其附加到存在instructionLabel的代碼中,然後從代碼中刪除instructionLabel,但忘記更新.xib