以 NSException 类型的未捕获异常终止 - Xcode
Posted
技术标签:
【中文标题】以 NSException 类型的未捕获异常终止 - Xcode【英文标题】:terminating with uncaught exception of type NSException - Xcode 【发布时间】:2015-07-02 02:47:29 【问题描述】:我正在使用 Xcode 6.4 并在尝试使用我硬编码的使用后退按钮时收到以下错误:
2015-07-01 22:41:47.082 oby[14979:280903] -[oby.PhotoViewController popView]: unrecognized selector sent to instance 0x7f8112f24d90
2015-07-01 22:41:47.103 oby[14979:280903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[oby.PhotoViewController popView]: unrecognized selector sent to instance 0x7f8112f24d90'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105b92c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001076fdbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105b9a0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000105af013c ___forwarding___ + 988
4 CoreFoundation 0x0000000105aefcd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000106432d62 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010654450a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x00000001065438d9 -[UIControl touchesEnded:withEvent:] + 522
8 UIKit 0x000000010647f958 -[UIWindow _sendTouchesForEvent:] + 735
9 UIKit 0x0000000106480282 -[UIWindow sendEvent:] + 682
10 UIKit 0x0000000106446541 -[UIApplication sendEvent:] + 246
11 UIKit 0x0000000106453cdc _UIApplicationHandleEventFromQueueEvent + 18265
12 UIKit 0x000000010642e59c _UIApplicationHandleEventQueue + 2066
13 CoreFoundation 0x0000000105ac6431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x0000000105abc2fd __CFRunLoopDoSources0 + 269
15 CoreFoundation 0x0000000105abb934 __CFRunLoopRun + 868
16 CoreFoundation 0x0000000105abb366 CFRunLoopRunSpecific + 470
17 GraphicsServices 0x000000010a676a3e GSEventRunModal + 161
18 UIKit 0x00000001064318c0 UIApplicationMain + 1282
19 oby 0x00000001053502b7 main + 135
20 libdyld.dylib 0x0000000107e33145 start + 1
21 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
按钮:
let btn = UINavButton(title: "Back", direction: UIButtonDirection.Left, parentView: self.view)
btn.addTarget(self, action: "popView", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(btn)
有人可以帮我解决这个问题吗?
谢谢!
【问题讨论】:
异常意味着你没有实例方法“popView”。 @RemingHsu 我该如何添加它?如您所知,它就在那里。 【参考方案1】:类似的东西
btn.addTarget(self, action: "backAction", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(btn)
func backAction()
self.navigationController?.popViewControllerAnimated(true)
【讨论】:
它给了我同样的错误,但这次是backAction
。有什么想法吗?
你解决了吗?确保您的操作是实例。
我唯一要做的改变是在action: "backAction:"
的末尾添加:
以上是关于以 NSException 类型的未捕获异常终止 - Xcode的主要内容,如果未能解决你的问题,请参考以下文章
Swift 项目以 NSException 类型的未捕获异常终止
以 NSException 类型的未捕获异常终止 - Xcode
libc+abi.dylib:以 NSException 类型的未捕获异常终止
以 NSException Timer Swift Crash 类型的未捕获异常终止