通过按钮单击切换视图控制器导致以NSException类型的未捕获异常终止

时间:2015-11-20 06:25:34

标签: ios swift viewcontroller

您好我正在创建一个应用程序,并希望使用一个按钮从一个视图控制器切换到另一个视图控制器。我使用了模态segue并调用了UIbutton performSegueWithIdentifier动作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) 。但是,我得到了

  

使用NSException类型的未捕获异常终止

AppleDelegate文件中的

错误。我不知道这里发生了什么。请帮我!非常感谢。 以下是该计划的解释:

SELECT * FROM Product JOIN buy ON Product.id = buy.id WHERE buy.userid = $user_id

2 个答案:

答案 0 :(得分:1)

当您意外地从.h文件中删除iboutlet但仍然在xib或storyboard中连接时会发生此错误。请确保在第二个视图中正确连接所有iboutlet。

答案 1 :(得分:0)

首先将类名设置为以下

enter image description here

然后设置segue标识符

enter image description here

如果您意外删除了任何IBOutlet,或者您以编程方式更改了控件名称,然后找不到相应的插座,请检查天气。