UITextField 触摸时崩溃
UITextField crash on touch
每当我点击以编程方式添加到我的视图的 UITextField
时,我的应用程序总是崩溃。如果有任何帮助,这里是堆栈跟踪:
'NSInvalidArgumentException', reason: '-[Clifford_Bradford.OtherVehiclesViewController numOfOtherVehiclesUpdated:]: unrecognized selector sent to instance 0x7fd92a57f8d0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107e5dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001099c8bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107e650ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107dbb13c ___forwarding___ + 988
4 CoreFoundation 0x0000000107dbacd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001086fdd62 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010880f50a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x0000000108e26d39 -[UITextField _resignFirstResponder] + 256
8 UIKit 0x0000000108e26bab -[UITextField _finishResignFirstResponder] + 45
9 UIKit 0x000000010888078b -[UIResponder resignFirstResponder] + 114
10 UIKit 0x0000000108e26b04 -[UITextField resignFirstResponder] + 114
11 UIKit 0x0000000108880575 -[UIResponder becomeFirstResponder] + 284
12 UIKit 0x000000010876fb81 -[UIView(Hierarchy) becomeFirstResponder] + 99
13 UIKit 0x0000000108e26307 -[UITextField becomeFirstResponder] + 51
14 UIKit 0x0000000108ab5d4e -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 177
15 UIKit 0x0000000108ab7dc0 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2263
16 UIKit 0x0000000108aad656 _UIGestureRecognizerSendActions + 262
17 UIKit 0x0000000108aac2f9 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 532
18 UIKit 0x0000000108ab0f16 ___UIGestureRecognizerUpdate_block_invoke662 + 51
19 UIKit 0x0000000108ab0e12 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 254
20 UIKit 0x0000000108aa6e8d _UIGestureRecognizerUpdate + 2796
21 UIKit 0x000000010874a646 -[UIWindow _sendGesturesForEvent:] + 1041
22 UIKit 0x000000010874b272 -[UIWindow sendEvent:] + 666
23 UIKit 0x0000000108711541 -[UIApplication sendEvent:] + 246
24 UIKit 0x000000010871ecdc _UIApplicationHandleEventFromQueueEvent + 18265
25 UIKit 0x00000001086f959c _UIApplicationHandleEventQueue + 2066
26 CoreFoundation 0x0000000107d91431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
27 CoreFoundation 0x0000000107d872fd __CFRunLoopDoSources0 + 269
28 CoreFoundation 0x0000000107d86934 __CFRunLoopRun + 868
29 CoreFoundation 0x0000000107d86366 CFRunLoopRunSpecific + 470
30 GraphicsServices 0x000000010be31a3e GSEventRunModal + 161
31 UIKit 0x00000001086fc8c0 UIApplicationMain + 1282
32 Clifford Bradford 0x0000000107c33bb7 main + 135
33 libdyld.dylib 0x000000010a0fe145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException`.
它只是将我指向 AppDelegate.swift
的第一行,这对我没有任何帮助。下面是将 textField
添加到视图的相应代码。我想补充一点,contView
在 scrollView
.
内
var otherVehiclePlateNum:UITextField = UITextField(frame: CGRectMake(carLabel.bounds.origin.x + 15, carLabel.frame.maxY + 10, self.contView.frame.width - 30, 25))
otherVehiclePlateNum.placeholder = "TEST"
self.contView.addSubview(otherVehiclePlateNum)
非常感谢你的帮助,我一直坚持这个。
看第一行:方法numOfOtherVehiclesUpdated:
是否真的存在于OtherVehiclesViewController
class中?确保如果你调用冒号与签名匹配的任何 @selector
s(即,你可能有一个 numOfOtherVehiclesUpdated
方法,它与 numOfOtherVehiclesUpdated:
不同一个参数)。
先看看那里 - 你可能不小心调用了它
每当我点击以编程方式添加到我的视图的 UITextField
时,我的应用程序总是崩溃。如果有任何帮助,这里是堆栈跟踪:
'NSInvalidArgumentException', reason: '-[Clifford_Bradford.OtherVehiclesViewController numOfOtherVehiclesUpdated:]: unrecognized selector sent to instance 0x7fd92a57f8d0' *** First throw call stack: ( 0 CoreFoundation 0x0000000107e5dc65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001099c8bb7 objc_exception_throw + 45 2 CoreFoundation 0x0000000107e650ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x0000000107dbb13c ___forwarding___ + 988 4 CoreFoundation 0x0000000107dbacd8 _CF_forwarding_prep_0 + 120 5 UIKit 0x00000001086fdd62 -[UIApplication sendAction:to:from:forEvent:] + 75 6 UIKit 0x000000010880f50a -[UIControl _sendActionsForEvents:withEvent:] + 467 7 UIKit 0x0000000108e26d39 -[UITextField _resignFirstResponder] + 256 8 UIKit 0x0000000108e26bab -[UITextField _finishResignFirstResponder] + 45 9 UIKit 0x000000010888078b -[UIResponder resignFirstResponder] + 114 10 UIKit 0x0000000108e26b04 -[UITextField resignFirstResponder] + 114 11 UIKit 0x0000000108880575 -[UIResponder becomeFirstResponder] + 284 12 UIKit 0x000000010876fb81 -[UIView(Hierarchy) becomeFirstResponder] + 99 13 UIKit 0x0000000108e26307 -[UITextField becomeFirstResponder] + 51 14 UIKit 0x0000000108ab5d4e -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 177 15 UIKit 0x0000000108ab7dc0 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2263 16 UIKit 0x0000000108aad656 _UIGestureRecognizerSendActions + 262 17 UIKit 0x0000000108aac2f9 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 532 18 UIKit 0x0000000108ab0f16 ___UIGestureRecognizerUpdate_block_invoke662 + 51 19 UIKit 0x0000000108ab0e12 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 254 20 UIKit 0x0000000108aa6e8d _UIGestureRecognizerUpdate + 2796 21 UIKit 0x000000010874a646 -[UIWindow _sendGesturesForEvent:] + 1041 22 UIKit 0x000000010874b272 -[UIWindow sendEvent:] + 666 23 UIKit 0x0000000108711541 -[UIApplication sendEvent:] + 246 24 UIKit 0x000000010871ecdc _UIApplicationHandleEventFromQueueEvent + 18265 25 UIKit 0x00000001086f959c _UIApplicationHandleEventQueue + 2066 26 CoreFoundation 0x0000000107d91431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 27 CoreFoundation 0x0000000107d872fd __CFRunLoopDoSources0 + 269 28 CoreFoundation 0x0000000107d86934 __CFRunLoopRun + 868 29 CoreFoundation 0x0000000107d86366 CFRunLoopRunSpecific + 470 30 GraphicsServices 0x000000010be31a3e GSEventRunModal + 161 31 UIKit 0x00000001086fc8c0 UIApplicationMain + 1282 32 Clifford Bradford 0x0000000107c33bb7 main + 135 33 libdyld.dylib 0x000000010a0fe145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException`.
它只是将我指向 AppDelegate.swift
的第一行,这对我没有任何帮助。下面是将 textField
添加到视图的相应代码。我想补充一点,contView
在 scrollView
.
var otherVehiclePlateNum:UITextField = UITextField(frame: CGRectMake(carLabel.bounds.origin.x + 15, carLabel.frame.maxY + 10, self.contView.frame.width - 30, 25))
otherVehiclePlateNum.placeholder = "TEST"
self.contView.addSubview(otherVehiclePlateNum)
非常感谢你的帮助,我一直坚持这个。
看第一行:方法numOfOtherVehiclesUpdated:
是否真的存在于OtherVehiclesViewController
class中?确保如果你调用冒号与签名匹配的任何 @selector
s(即,你可能有一个 numOfOtherVehiclesUpdated
方法,它与 numOfOtherVehiclesUpdated:
不同一个参数)。
先看看那里 - 你可能不小心调用了它