不符合键值编码

发布于 2024-11-19 23:33:56 字数 3898 浏览 3 评论 0原文

我正在尝试将 ViewController 连接到 TabController 中的选项卡。我已将选项卡类型设置为 NavigationController,并将我的 ViewController 子类设置为选项卡的标识。我还设置了该选项卡的 NIB 名称。当我将任何其他选项卡与 NavigationContollers 一起使用时,一切正常,但一个特定视图引发异常,此类与键 txtPassword 不兼容键值编码。

2011-07-14 17:11:10.784 myApp[5027:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x5a36500> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key txtPassword.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x013305a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x01484313 objc_exception_throw + 44
    2   CoreFoundation                      0x013304e1 -[NSException raise] + 17
    3   Foundation                          0x00195677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x001955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0061930c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x012a68cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x00617d23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x00619ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x004cf628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x004cd134 -[UIViewController loadView] + 120
    11  UIKit                               0x004cd00e -[UIViewController view] + 56
    12  UIKit                               0x004cb482 -[UIViewController contentScrollView] + 42
    13  UIKit                               0x004dbf25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
    14  UIKit                               0x004da555 -[UINavigationController _layoutViewController:] + 43
    15  UIKit                               0x004db870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
    16  UIKit                               0x004d632a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
    17  UIKit                               0x005f12e9 -[UILayoutContainerView layoutSubviews] + 226
    18  QuartzCore                          0x00f5aa5a -[CALayer layoutSublayers] + 181
    19  QuartzCore                          0x00f5cddc CALayerLayoutIfNeeded + 220
    20  QuartzCore                          0x00f020b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
    21  QuartzCore                          0x00f03294 _ZN2CA11Transaction6commitEv + 292
    22  QuartzCore                          0x00f0346d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
    23  CoreFoundation                      0x0131189b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
    24  CoreFoundation                      0x012a66e7 __CFRunLoopDoObservers + 295
    25  CoreFoundation                      0x0126f1d7 __CFRunLoopRun + 1575
    26  CoreFoundation                      0x0126e840 CFRunLoopRunSpecific + 208
    27  CoreFoundation                      0x0126e761 CFRunLoopRunInMode + 97
    28  GraphicsServices                    0x01acd1c4 GSEventRunModal + 217
    29  GraphicsServices                    0x01acd289 GSEventRun + 115
    30  UIKit                               0x0042bc93 UIApplicationMain + 1160
    31  myApp                           0x00001f44 main + 102
    32  myApp                           0x00001ed5 start + 53
)
terminate called after throwing an instance of 'NSException'

该属性的声明如下ViewController 的接口(UINavigationViewController 的子类并作为属性公开。它也像其他控件一样在 IB 中合成和连接,但由于某种原因抛出此异常。

有什么方法可以追踪原因吗?

I'm trying to get a ViewController hooked up to a tab in a TabController. I've set the tab type to be a NavigationController, and my ViewController subclass as the tab's identity. I've also set the NIB name for the tab. When I use any of the other tabs with NavigationContollers, everything works, yet one particular view throws an exception, this class is not key value coding-compliant for the key txtPassword.

2011-07-14 17:11:10.784 myApp[5027:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x5a36500> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key txtPassword.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x013305a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x01484313 objc_exception_throw + 44
    2   CoreFoundation                      0x013304e1 -[NSException raise] + 17
    3   Foundation                          0x00195677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x001955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0061930c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x012a68cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x00617d23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x00619ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x004cf628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x004cd134 -[UIViewController loadView] + 120
    11  UIKit                               0x004cd00e -[UIViewController view] + 56
    12  UIKit                               0x004cb482 -[UIViewController contentScrollView] + 42
    13  UIKit                               0x004dbf25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
    14  UIKit                               0x004da555 -[UINavigationController _layoutViewController:] + 43
    15  UIKit                               0x004db870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
    16  UIKit                               0x004d632a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
    17  UIKit                               0x005f12e9 -[UILayoutContainerView layoutSubviews] + 226
    18  QuartzCore                          0x00f5aa5a -[CALayer layoutSublayers] + 181
    19  QuartzCore                          0x00f5cddc CALayerLayoutIfNeeded + 220
    20  QuartzCore                          0x00f020b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
    21  QuartzCore                          0x00f03294 _ZN2CA11Transaction6commitEv + 292
    22  QuartzCore                          0x00f0346d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
    23  CoreFoundation                      0x0131189b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
    24  CoreFoundation                      0x012a66e7 __CFRunLoopDoObservers + 295
    25  CoreFoundation                      0x0126f1d7 __CFRunLoopRun + 1575
    26  CoreFoundation                      0x0126e840 CFRunLoopRunSpecific + 208
    27  CoreFoundation                      0x0126e761 CFRunLoopRunInMode + 97
    28  GraphicsServices                    0x01acd1c4 GSEventRunModal + 217
    29  GraphicsServices                    0x01acd289 GSEventRun + 115
    30  UIKit                               0x0042bc93 UIApplicationMain + 1160
    31  myApp                           0x00001f44 main + 102
    32  myApp                           0x00001ed5 start + 53
)
terminate called after throwing an instance of 'NSException'

The property is declared as in the interface for the ViewController (a subclass of UINavigationViewController and exposed as a property. It's also synthesized and hooked up in IB like the rest of the controls, yet for some reason throws this exception.

Is there any way to track down the cause?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞梦里开花 2024-11-26 23:33:56

您的 .xib 可能在未定义的视图中引用了 txtPassword 属性 - 例如缺少 @synthesize。

Your .xib probably references a txtPassword property in the view that is not defined - e.g. the @synthesize is missing.

人心善变 2024-11-26 23:33:56

事实证明,我将 UITabController 中选项卡的类标识设置为 UINavigationController 子类的实例,并将选项卡的类型设置为导航控制器。我需要的是在选项卡中设置 UIView 的类标识,而不是选项卡本身。

It turned out I had the class identity of a Tab in my UITabController set to an instance of a UINavigationController subclass, and the tab's type was set to navigation controller. What I needed was to set the class identity of the UIView within the tab, not the tab itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文