改为 UIControl 点击后应用直接奔溃

2018-01-30 17:20:13 +08:00
 ech0x

一个单页应用,并且只有一个 Text Field 控件,我在 StoryBoard 中把 UIview 改成 UIControl 以后,无论在什么情况下点按空白处,应用都会直接崩溃。

ViewControler 类里面也是空的。

崩溃日志如下:

2018-01-30 17:11:58.500306+0800 LearniOSDev[49254:6680144] [MC] Lazy loading NSBundle MobileCoreServices.framework
2018-01-30 17:11:58.500578+0800 LearniOSDev[49254:6680144] [MC] Loaded MobileCoreServices.framework
2018-01-30 17:12:02.525683+0800 LearniOSDev[49254:6680144] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/flegde/Library/Developer/CoreSimulator/Devices/DF0FF0EC-862D-4A25-A187-301AA650D6B1/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-01-30 17:12:02.532306+0800 LearniOSDev[49254:6680144] [MC] Reading from private effective user settings.
2018-01-30 17:12:03.820409+0800 LearniOSDev[49254:6680144] -[LearniOSDev.ViewController backgrounTap:]: unrecognized selector sent to instance 0x7fe904612520
2018-01-30 17:12:03.832523+0800 LearniOSDev[49254:6680144] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LearniOSDev.ViewController backgrounTap:]: unrecognized selector sent to instance 0x7fe904612520'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000107ec712b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010424ef41 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000107f48024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   UIKit                               0x0000000104d1ef51 -[UIResponder doesNotRecognizeSelector:] + 295
	4   CoreFoundation                      0x0000000107e49f78 ___forwarding___ + 1432
	5   CoreFoundation                      0x0000000107e49958 _CF_forwarding_prep_0 + 120
	6   UIKit                               0x0000000104aec972 -[UIApplication sendAction:to:from:forEvent:] + 83
	7   UIKit                               0x0000000104c6bc3c -[UIControl sendAction:to:forEvent:] + 67
	8   UIKit                               0x0000000104c6bf59 -[UIControl _sendActionsForEvents:withEvent:] + 450
	9   UIKit                               0x0000000104c6a981 -[UIControl touchesBegan:withEvent:] + 282
	10  UIKit                               0x0000000104b62562 -[UIWindow _sendTouchesForEvent:] + 2130
	11  UIKit                               0x0000000104b63f2a -[UIWindow sendEvent:] + 4124
	12  UIKit                               0x0000000104b07365 -[UIApplication sendEvent:] + 352
	13  UIKit                               0x000000012154349d -[UIApplicationAccessibility sendEvent:] + 85
	14  UIKit                               0x0000000105453a1d __dispatchPreprocessedEventFromEventQueue + 2809
	15  UIKit                               0x0000000105456672 __handleEventQueueInternal + 5957
	16  CoreFoundation                      0x0000000107e6a101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	17  CoreFoundation                      0x0000000107f09f71 __CFRunLoopDoSource0 + 81
	18  CoreFoundation                      0x0000000107e4ea19 __CFRunLoopDoSources0 + 185
	19  CoreFoundation                      0x0000000107e4dfff __CFRunLoopRun + 1279
	20  CoreFoundation                      0x0000000107e4d889 CFRunLoopRunSpecific + 409
	21  GraphicsServices                    0x000000010a6539c6 GSEventRunModal + 62
	22  UIKit                               0x0000000104aeb5d6 UIApplicationMain + 159
	23  LearniOSDev                         0x000000010393ae47 main + 55
	24  libdyld.dylib                       0x0000000109065d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
6363 次点击
所在节点    iDev
7 条回复
axknightroad
2018-01-30 18:50:29 +08:00
`backgrounTap:` 方法没实现吧
SeanChense
2018-01-30 18:54:21 +08:00
应该是你没把 sb 中的点击事件跟代码连在一起吧
ech0x
2018-01-30 19:47:22 +08:00
@SeanChense 实现了。。。。。
@axknightroad
ech0x
2018-01-30 19:49:29 +08:00
@axknightroad
@SeanChense 是老方法忘了删了。。。。。😂😂😂没事了
gmykissqiqi
2018-02-08 16:00:33 +08:00
unrecognized selector sent to instance
gmykissqiqi
2018-02-08 16:00:50 +08:00
unrecognized selector sent to instance
这里已经说得很清楚了啊
ech0x
2018-02-09 01:33:24 +08:00
@gmykissqiqi 嗯嗯,谢谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/427164

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX