UITextField 触摸时崩溃 -- iOS8

UITextField Crash on Touch -- iOS8

我的项目在 iOS7 上运行良好。但是当我在 iOs8 上尝试时,UITextFields 使应用程序崩溃。我将一个全新的 UITextField 添加到我的故事板之一并触摸新创建的 UITextField(没有代表附加到文本字段),应用程序再次崩溃。 我花了整整几天的时间,非常感谢你的帮助。

(
    0   CoreFoundation                      0x000000010d71af35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d3afbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010d721f4d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010d67a27c ___forwarding___ + 988
    4   CoreFoundation                      0x000000010d679e18 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x000000010d60d13d CFStringGetCString + 173
    6   CoreFoundation                      0x000000010d6316ac CFLocaleCreateCanonicalLanguageIdentifierFromString + 76
    7   CoreFoundation                      0x000000010d698e0f CFStringTokenizerCreate + 847
    8   UIKit                               0x000000010c3b6d58 __91-[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:]_block_invoke44 + 253
    9   UIFoundation                        0x00000001154f406b -[NSTextStorage coordinateReading:] + 42
    10  UIKit                               0x000000010c3b6a29 -[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:] + 322
    11  UIKit                               0x000000010c0b279c -[UITextInputStringTokenizer positionFromPosition:toBoundary:inDirection:] + 72
    12  UIKit                               0x000000010c0b2e4e -[TIDocumentState(UITextInputAdditions) _contextBeforePosition:inDocument:] + 68
    13  UIKit                               0x000000010c0b2f91 -[TIDocumentState(UITextInputAdditions) initWithDocument:] + 110
    14  UIKit                               0x000000010c0b2aea +[TIDocumentState(UITextInputAdditions) documentStateOfDocument:] + 50
    15  UIKit                               0x000000010be49683 -[UIKeyboardImpl syncDocumentStateToInputDelegateWithExecutionContext:] + 288
    16  UIKit                               0x000000010be49edb -[UIKeyboardImpl updateForChangedSelectionWithExecutionContext:] + 296
    17  UIKit                               0x000000010c3b7914 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 332
    18  UIKit                               0x000000010be4471f -[UIKeyboardImpl setDelegate:force:] + 2031
    19  UIKit                               0x000000010c112a12 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 902
    20  UIKit                               0x000000010bdcf31d -[UIResponder becomeFirstResponder] + 468
    21  UIKit                               0x000000010bcc4e03 -[UIView(Hierarchy) becomeFirstResponder] + 99
    22  UIKit                               0x000000010c38bad7 -[UITextField becomeFirstResponder] + 51
    23  UIKit                               0x000000010c0139c1 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 177
    24  UIKit                               0x000000010c015a30 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2263
    25  UIKit                               0x000000010c00b2e6 _UIGestureRecognizerSendActions + 262
    26  UIKit                               0x000000010c009f89 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 532
    27  UIKit                               0x000000010c00eba6 ___UIGestureRecognizerUpdate_block_invoke662 + 51
    28  UIKit                               0x000000010c00eaa2 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 254
    29  UIKit                               0x000000010c004b1d _UIGestureRecognizerUpdate + 2796
    30  UIKit                               0x000000010bc9eff6 -[UIWindow _sendGesturesForEvent:] + 1041
    31  UIKit                               0x000000010bc9fc23 -[UIWindow sendEvent:] + 667
    32  UIKit                               0x000000010bc6c9b1 -[UIApplication sendEvent:] + 246
    33  UIKit                               0x000000010bc79a7d _UIApplicationHandleEventFromQueueEvent + 17370
    34  UIKit                               0x000000010bc55103 _UIApplicationHandleEventQueue + 1961
    35  CoreFoundation                      0x000000010d650551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    36  CoreFoundation                      0x000000010d64641d __CFRunLoopDoSources0 + 269
    37  CoreFoundation                      0x000000010d645a54 __CFRunLoopRun + 868
    38  CoreFoundation                      0x000000010d645486 CFRunLoopRunSpecific + 470
    39  GraphicsServices                    0x00000001121bd9f0 GSEventRunModal + 161
    40  UIKit                               0x000000010bc58420 UIApplicationMain + 1282
    41  FIM                                 0x00000001092d88e1 main + 65
    42  libdyld.dylib                       0x000000010de50145 start + 1

出于某种原因 Sergiy Salyuk 没有 post 回答,但他的评论有效。

问题在于用 NSUserDefaults

替换 "AppleLanguages" 中的初始语言数组

它节省了很多时间,因为问题只出现在测试设备上,而在其他国家,我不知道如何找出崩溃与此跟踪和 "AppleLanguages" 在 NSUserDefaults.

再一次谢谢你 Sergiy。