UITableViewCell中的UITextField在键入时崩溃

时间:2016-01-19 19:18:20

标签: ios swift uitableview

编辑:我已经确定我的旧布局是糟糕的用户体验设计并且已经改变。我不再需要在UITextFields中拥有UITableViewCell

我有一个包含两个UITableViewCell的自定义UITextFields 我可以滚动得很好并选择,或将选择更改为任何其他文本字段,但当我按下键盘上的任何按钮时,我会崩溃。这发生在模拟器和真实设备上。我可以将内容粘贴到文本字段

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull >ength]: unrecognized selector sent to instance 0x1066deaf0'
** First throw call stack:

    0   CoreFoundation                      0x00000001064b9e65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001081f9deb objc_exception_throw + 48
    2   CoreFoundation                      0x00000001064c248d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010640f90a ___forwarding___ + 970
    4   CoreFoundation                      0x000000010640f4b8 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x0000000106391dfa CFStringCompareWithOptionsAndLocale + 202
    6   Foundation                          0x000000010684ce37 -[NSString compare:options:range:] + 29
    7   UIKit                               0x0000000106fc0e6f -[UIPhysicalKeyboardEvent _matchesKeyCommand:] + 303
    8   UIKit                               0x0000000106ee53fd -[UIResponder _keyCommandForEvent:target:] + 364
    9   UIKit                               0x0000000106ee55b2 -[UIResponder _keyCommandForEvent:target:] + 801
    10  UIKit                               0x0000000106ee55b2 -[UIResponder _keyCommandForEvent:target:] + 801
    11  UIKit                               0x0000000106ee55b2 -[UIResponder _keyCommandForEvent:target:] + 801
    12  UIKit                               0x0000000106ee55b2 -[UIResponder _keyCommandForEvent:target:] + 801
    13  UIKit                               0x0000000106ee55b2 -[UIResponder _keyCommandForEvent:target:] + 801
    14  UIKit                               0x0000000106cf791a -[UIApplication _handleKeyUIEvent:] + 948
    15  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    16  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    17  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    18  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    19  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    20  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    21  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    22  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    23  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    24  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    25  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    26  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    27  UIKit                               0x0000000106ee5e53 -[UIResponder _handleKeyUIEvent:] + 79
    28  UIKit                               0x0000000106cf72cd -[UIApplication handleKeyUIEvent:] + 79
    29  UIKit                               0x0000000106f8dc83 -[UIKeyboardImpl _handleKeyEvent:executionContext:] + 66
    30  UIKit                               0x000000010718dcde -[UIKeyboardLayoutStar completeRetestForTouchUp:timestamp:interval:executionContext:] + 3356
    31  UIKit                               0x0000000106f9cbbd __28-[UIKeyboardLayout touchUp:]_block_invoke + 228
    32  UIKit                               0x00000001076e9724 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 332
    33  UIKit                               0x0000000106f9cace -[UIKeyboardLayout touchUp:] + 236
    34  UIKit                               0x0000000106f9d614 -[UIKeyboardLayout touchesEnded:withEvent:] + 348
    35  UIKit                               0x0000000106d4749b -[UIWindow _sendTouchesForEvent:] + 835
    36  UIKit                               0x0000000106d481d0 -[UIWindow sendEvent:] + 865
    37  UIKit                               0x0000000106cf6b66 -[UIApplication sendEvent:] + 263
    38  UIKit                               0x0000000106cd0d97 _UIApplicationHandleEventQueue + 6844
    39  CoreFoundation                      0x00000001063e5a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    40  CoreFoundation                      0x00000001063db95c __CFRunLoopDoSources0 + 556
    41  CoreFoundation                      0x00000001063dae13 __CFRunLoopRun + 867
    42  CoreFoundation                      0x00000001063da828 CFRunLoopRunSpecific + 488
    43  GraphicsServices                    0x000000010a6a5ad2 GSEventRunModal + 161
    44  UIKit                               0x0000000106cd6610 UIApplicationMain + 171
    45  APP NAME                0x0000000105acf65d main + 109
    46  libdyld.dylib                       0x0000000108d0b92d start + 1
    47  ???                                 0x0000000000000001 0x0 + 1

我的UITableViewController被设为我UITextFields的代理人。

func textFieldDidBeginEditing(textField: UITextField) {
        print("Did Begin Editing")
}
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        print("Should Change Char")
        return true
}

是否已开始编辑,但应更改char不是。

0 个答案:

没有答案