故事板触发器 Segue 上的未捕获错误

Uncaught Error on Storyboard Trigger Segue

我正在使用情节提要,当我触发 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

我的故事板是这样的:(当我从左到右打开 4th-->5th segue 时出现异常)

如果你有什么想法,请帮我解决一下。

错误确实说明了问题,您只需要仔细阅读即可:

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.'

这意味着 class 试图通过键值编码在对象上设置 属性,但失败了。如果您定义一个 IBOutlet 并将其连接到 Storyboards 中,则可能会发生这种情况;然后稍后删除代码中的出口并导致情节提要具有悬空连接。在这种情况下,有问题的部分似乎在 ProductDetailController 中,您应该返回那里并检查您所做的更改,而不相应地更新您的故事板。