ios - 通过单击按钮切换 View Controller 会导致以 NSException 类型的未捕获异常终止

标签 ios swift viewcontroller

您好,我正在制作一个应用程序,想使用一个按钮从一个 View Controller 切换到另一个 View Controller 。我使用了模态转场并创建了一个调用 performSegueWithIdentifierUIbutton 操作。然而,我得到了

Terminating with uncaught exception of type NSException

AppleDelegate 文件中的错误。我不知道这里发生了什么。请帮我!多谢。 以下是该程序的解释:

2015-11-20 01:22:21.575 Photo book[17126:547637] Unknown class ViewController1 in Interface Builder file.
2015-11-20 01:22:21.581 Photo book[17126:547637] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7f9698e1d2b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Open.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103d7fc65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000103a18bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000103d7f8a9 -[NSException raise] + 9
    3   Foundation                          0x00000001035aeb53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
    4   CoreFoundation                      0x0000000103cc7d50 -[NSArray makeObjectsPerformSelector:] + 224
    5   UIKit                               0x000000010469252b -[UINib instantiateWithOwner:options:] + 1506
    6   UIKit                               0x00000001048f4aba -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
    7   UIKit                               0x00000001048f80bf -[UIStoryboardSegueTemplate _perform:] + 71
    8   UIKit                               0x0000000111251638 -[UIViewControllerAccessibility performSegueWithIdentifier:sender:] + 39
    9   Photo book                          0x0000000103479c66 _TFC10Photo_book14ViewController5LoginfS0_FCSo8UIButtonT_ + 278
    10  Photo book                          0x0000000103479cea _TToFC10Photo_book14ViewController5LoginfS0_FCSo8UIButtonT_ + 58
    11  UIKit                               0x00000001043bbda2 -[UIApplication sendAction:to:from:forEvent:] + 75
    12  UIKit                               0x00000001044cd54a -[UIControl _sendActionsForEvents:withEvent:] + 467
    13  UIKit                               0x00000001044cc919 -[UIControl touchesEnded:withEvent:] + 522
    14  UIKit                               0x0000000104408998 -[UIWindow _sendTouchesForEvent:] + 735
    15  UIKit                               0x00000001044092c2 -[UIWindow sendEvent:] + 682
    16  UIKit                               0x00000001043cf581 -[UIApplication sendEvent:] + 246
    17  UIKit                               0x00000001043dcd1c _UIApplicationHandleEventFromQueueEvent + 18265
    18  UIKit                               0x00000001043b75dc _UIApplicationHandleEventQueue + 2066
    19  CoreFoundation                      0x0000000103cb3431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    20  CoreFoundation                      0x0000000103ca92fd __CFRunLoopDoSources0 + 269
    21  CoreFoundation                      0x0000000103ca8934 __CFRunLoopRun + 868
    22  CoreFoundation                      0x0000000103ca8366 CFRunLoopRunSpecific + 470
    23  GraphicsServices                    0x00000001085cda3e GSEventRunModal + 161
    24  UIKit                               0x00000001043ba900 UIApplicationMain + 1282
    25  Photo book                          0x000000010348b1c7 main + 135
    26  libdyld.dylib                       0x0000000106965145 start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

最佳答案

当您不小心从 .h 文件中删除了 iboutlet 但它们在您的 xib 或 Storyboard中仍然连接时会发生此错误。请确保您的所有 iboutlet 在您的第二个 View 中正确连接。

关于ios - 通过单击按钮切换 View Controller 会导致以 NSException 类型的未捕获异常终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33820256/

相关文章:

ios - 在Swift iOS中计算整数数组中每5个元素的总和

ios - 单击 UIButton 时没有任何反应

iphone - NSNotificationCenter postNotificationName exec_badaccess

swift - 在 Swift 中使用 UserDefaults 保存 SCNVector3 的值

swift - 如何更改容器 View (嵌入式 View Controller )中的 View ?

macos - 在 NSTabView 上加载同一 NSViewController 的不同实例

ios - iOS Objective-C 中的多线程

ios - 如何确保只有一个 iOS 应用程序实例在运行?

ios - swift 3 : Instance Member cannot be used on type “View Controller”

swift - 无法遍历 <String : Any> 字典的数组元素