我正在使用Storyboard,当我触发segue时,我收到一些错误:Uncaught Exception:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CommercerApp.ProductDetailController 0x78ff1030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key contentView.'
*** First throw call stack:
(
0 CoreFoundation 0x00c9f946 _exceptionPreprocess + 182
1 libobjc.A.dylib 0x00928a97 objc_exception_throw + 44
2 CoreFoundation 0x00c9f561 -[NSException raise] + 17
3 Foundation 0x005b010e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x0050c138 _NSSetUsingKeyValueSetter + 115
5 Foundation 0x0050c0bd -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x005419a6 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 386
7 UIKit 0x01639649 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x0093e724 -[NSObject performSelector:] + 62
9 CoreFoundation 0x00bd95dc -[NSArray makeObjectsPerformSelector:] + 316
10 UIKit 0x0163810a -[UINib instantiateWithOwner:options:] + 1775
11 UIKit 0x0145a624 -[UIViewController _loadViewFromNibNamed:bundle:] + 270
12 UIKit 0x0145adbb -[UIViewController loadView] + 295
13 UIKit 0x0145afef -[UIViewController loadViewIfRequired] + 78
14 UIKit 0x0145b595 -[UIViewController view] + 35
15 UIKit 0x0149c534 -[UINavigationController preferredContentSize] + 161
16 UIKit 0x0143644d -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 122
17 UIKit 0x01433922 _56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 156
18 UIKit 0x014677ab _40+[UIViewController _scheduleTransition:]_block_invoke + 18
19 UIKit 0x0132d0ce __afterCACommitHandler_block_invoke + 15
20 UIKit 0x0132d079 _applyBlockToCFArrayCopiedToStack + 415
21 UIKit 0x0132ce8e _afterCACommitHandler + 545
22 CoreFoundation 0x00bc29de _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
23 CoreFoundation 0x00bc2920 _CFRunLoopDoObservers + 400
24 CoreFoundation 0x00bb835a _CFRunLoopRun + 1226
25 CoreFoundation 0x00bb7bcb CFRunLoopRunSpecific + 443
26 CoreFoundation 0x00bb79fb CFRunLoopRunInMode + 123
27 GraphicsServices 0x0526024f GSEventRunModal + 192
28 GraphicsServices 0x0526008c GSEventRun + 104
29 UIKit 0x013038b6 UIApplicationMain + 1526
30 CommercerApp 0x0012dbce top_level_code + 78
31 CommercerApp 0x0012dc0b main + 43
32 libdyld.dylib 0x02b24ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我的故事板是这样的:(当我打开第4时我得到例外 - &gt;从左到右第5个segue)
如果您有任何想法,请帮我解决。
答案 0 :(得分:1)
错误确实解释了问题,你只需要仔细阅读:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CommercerApp.ProductDetailController 0x78ff1030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key contentView.'
让我为你突出显示:
reason: '[<CommercerApp.ProductDetailController 0x78ff1030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key contentView.'
这意味着一个类正在尝试通过键值编码在对象上设置属性,并且失败了。如果您定义IBOutlet
并在故事板中将其挂钩,则可能会发生这种情况;然后删除代码中的插座并导致故事板具有悬空连接。在这种情况下,有问题的部分似乎在ProductDetailController
中,您应该回到那里并检查您已更改的内容,而无需相应地更新您的故事板。