gpt4 book ai didi

ios - UITextField 触摸时崩溃

转载 作者:行者123 更新时间:2023-11-30 14:10:47 25 4
gpt4 key购买 nike

每当我点击以编程方式添加到 View 中的 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`.

It just points me to the first line of the AppDelegate.swift which doesn't really help me. Here is the corresponding code that adds the textField to the view. I would like to add that the contView is inside a 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类中?确保如果您调用冒号与签名匹配的任何 @selector(即,您可能有一个 numOfOtherVehiclesUpdated 方法,该方法与numOfOtherVehiclesUpdated:,它带有一个参数)。

先看看那里 - 你可能会不小心调用它

关于ios - UITextField 触摸时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31799844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com