首先,我限制输入字符,仅包括数字和字母。 当控制器旋转到横向时,我输入一个特殊符号,例如'*'。 之后,我点击红框中的按钮App Crash!
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x181c5a1c0 __exceptionPreprocess + 124 (NSException.m:165)
1 libobjc.A.dylib 0x18069455c objc_exception_throw + 56 (objc-exception.mm:521)
2 CoreFoundation 0x181c61278 -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:328)
3 CoreFoundation 0x181c5e278 ___forwarding___ + 916 (NSForwarding.m:3120)
4 CoreFoundation 0x181b5859c _CF_forwarding_prep_0 + 92
5 UIKit 0x187bd0248 -[UIKeyboardImpl shouldShowCandidateBar] + 164 (UIKeyboardImpl.m:4261)
6 UIKit 0x187ae0194 -[UIKeyboardImpl updateTextCandidateView] + 508 (UIKeyboardImpl.m:8597)
7 UIKit 0x187adf498 -[UIKeyboardImpl clearInput] + 156 (UIKeyboardImpl.m:7663)
8 UIKit 0x187af6028 -[UIKeyboardImpl updateForChangedSelectionWithExecutionContext:] + 280 (UIKeyboardImpl.m:4782)
9 UIKit 0x187adf26c -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 384 (UIKeyboardTaskQueue.m:290)
10 UIKit 0x188531c74 -[UIKeyboardTaskQueue addAndReturnTask:] + 132 (UIKeyboardTaskQueue.m:410)
11 UIKit 0x188531ee4 -[UIKeyboardTaskQueue performSingleTask:] + 248 (UIKeyboardTaskQueue.m:484)
12 UIKit 0x187c67120 -[UIKeyboardImpl updateForChangedSelection] + 92 (UIKeyboardImpl.m:4753)
13 UIKit 0x187af495c -[UIKeyboardImpl selectionDidChange:] + 112 (UIKeyboardImpl.m:4867)
14 UIKit 0x187af4404 __52-[UITextInputController _coordinateSelectionChange:]_block_invoke + 152 (UITextInputController.m:653)
15 UIFoundation 0x187a2fd74 -[NSTextStorage coordinateReading:] + 56 (NSTextStorage.m:383)
16 UIKit 0x187af4338 -[UITextInputController _coordinateSelectionChange:] + 156 (UITextInputController.m:639)
17 UIKit 0x187cea998 -[UITextInputController selectAll] + 80 (UITextInputController.m:2774)
18 UIKit 0x187cea89c -[UITextInputController clearText] + 48 (UITextInputController.m:2331)
19 UIKit 0x187cea740 -[UITextField _clearButtonClicked:] + 376 (UITextField.m:5734)
20 UIKit 0x187aea484 -[UIApplication sendAction:to:from:forEvent:] + 96 (UIApplication.m:4582)
21 UIKit 0x187aea404 -[UIControl sendAction:to:forEvent:] + 80 (UIControl.m:609)
22 UIKit 0x187ad48b8 -[UIControl _sendActionsForEvents:withEvent:] + 452 (UIControl.m:694)
23 UIKit 0x187ae9cf0 -[UIControl touchesEnded:withEvent:] + 584 (UIControl.m:446)
24 UIKit 0x187ae9818 -[UIWindow _sendTouchesForEvent:] + 2484 (UIWindow.m:2120)
25 UIKit 0x187ae4a60 -[UIWindow sendEvent:] + 2988 (UIWindow.m:2290)
26 UIKit 0x187ab552c -[UIApplication sendEvent:] + 340 (UIApplication.m:10719)
27 UIKit 0x1882a2a54 __dispatchPreprocessedEventFromEventQueue + 2736 (UIEventDispatcher.m:1426)
28 UIKit 0x18829c4bc __handleEventQueue + 784 (UIEventDispatcher.m:1622)
29 CoreFoundation 0x181c08278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
30 CoreFoundation 0x181c07bc0 __CFRunLoopDoSources0 + 524 (CFRunLoop.c:1989)
31 CoreFoundation 0x181c057c0 __CFRunLoopRun + 804 (CFRunLoop.c:2821)
32 CoreFoundation 0x181b34048 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)
33 GraphicsServices 0x1835ba198 GSEventRunModal + 180 (GSEvent.c:2245)
34 UIKit 0x187b202fc -[UIApplication _run] + 684 (UIApplication.m:2649)
35 UIKit 0x187b1b034 UIApplicationMain + 208 (UIApplication.m:4091)
36 LCIphoneAdhocIP 0x1002e5acc main + 88 (main.m:17)
37 libdyld.dylib 0x180b185b8 start + 4
答案 0 :(得分:0)
CoreFoundation 0x181c61278 - [NSObject(NSObject) doesNotRecognizeSelector:] + 140(NSObject.m:328)
你给了一些" *"按回车键时返回的textField既不是数字也不是Alpha。
所以它无法识别@selector。因此,改变您的键盘类型,如用户将无法输入这样的错误符号。
我更喜欢
[textField1.keyboardType = UIKeyboardTypeAlphabet];