我一按东西,我的iOS应用就会崩溃。当我按下密码文本框或其他任何东西时,它就会崩溃。下面的代码:
import UIKit
import FirebaseDatabase
class SecondRegisterViewController: UIViewController {
var ref: DatabaseReference!
@IBOutlet weak var UsernameText: UITextField!
@IBOutlet weak var PasswordText: UITextField!
@IBOutlet weak var ConfirmText: UITextField!
@IBOutlet weak var FirstNameText: UITextField!
@IBOutlet weak var MiddleNameText: UITextField!
@IBOutlet weak var LastNameText: UITextField!
@IBOutlet weak var EmailText: UITextField!
@IBOutlet weak var NextButton: UIButton!
@IBAction func NextButton(_ sender: Any) {
ref?.child("Usernames").childByAutoId().setValue(UsernameText.text)
ref?.child("Passwords").childByAutoId().setValue(PasswordText.text)
ref?.child("First Names").childByAutoId().setValue(FirstNameText.text)
ref?.child("Last Names").childByAutoId().setValue(LastNameText.text)
ref?.child("Middle Names").childByAutoId().setValue(MiddleNameText.text)
ref?.child("Emails").childByAutoId().setValue(EmailText.text)
}
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference()
NextButton.isHidden = false
if UsernameText.text?.isEmpty == false && PasswordText.text?.isEmpty == false &&
ConfirmText.text?.isEmpty == false &&
FirstNameText.text?.isEmpty == false &&
MiddleNameText.text?.isEmpty == false &&
LastNameText.text?.isEmpty == false &&
EmailText.text?.isEmpty == false{
NextButton.isHidden = false
}
}
}
它也说:
libc ++ abi.dylib:以类型为NSException的未捕获异常终止
这是一个大问题,我将不胜感激。
我完全连接了以下所有插座和完整的控制台:
2018-07-29 06:50:33.225228+0530 SchoolDrive[22497:4253058] -[SchoolDrive.SecondRegisterViewController UsernameText:]: unrecognized selector sent to instance 0x7ffc57c2e840 2018-07-29 06:50:33.321943+0530 SchoolDrive[22497:4253058] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SchoolDrive.SecondRegisterViewController UsernameText:]: unrecognized selector sent to instance 0x7ffc57c2e840' *** First throw call stack: ( 0 CoreFoundation 0x00000001036381e6 __exceptionPreprocess + 294 1 libobjc.A.dylib 0x0000000102ccd031 objc_exception_throw + 48 2 CoreFoundation 0x00000001036b9784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 UIKit 0x0000000103ce36db -[UIResponder doesNotRecognizeSelector:] + 295 4 CoreFoundation 0x00000001035ba898 ___forwarding___ + 1432 5 CoreFoundation 0x00000001035ba278 _CF_forwarding_prep_0 + 120 6 UIKit 0x0000000103ab63e8 -[UIApplication sendAction:to:from:forEvent:] + 83 7 UIKit 0x0000000103c317a4 -[UIControl sendAction:to:forEvent:] + 67 8 UIKit 0x0000000103c31ac1 -[UIControl _sendActionsForEvents:withEvent:] + 450 9 UIKit 0x00000001047ca2a0 -[UITextField _resignFirstResponder] + 155 10 UIKit 0x0000000103ce30c8 -[UIResponder _finishResignFirstResponder] + 286 11 UIKit 0x00000001047c9ebf -[UITextField _finishResignFirstResponder] + 48 12 UIKit 0x0000000103ce3177 -[UIResponder resignFirstResponder] + 140 13 UIKit 0x00000001047c9d8f -[UITextField resignFirstResponder] + 135 14 UIKit 0x0000000103ce2df0 -[UIResponder becomeFirstResponder] + 655 15 UIKit 0x0000000103b6cb68 -[UIView(Hierarchy) becomeFirstResponder] + 145 16 UIKit 0x00000001047c8aff -[UITextField becomeFirstResponder] + 110 17 UIKit 0x0000000103dbf389 -[UIKeyboardImpl handleTabWithShift:beforePublicKeyCommands:] + 384 18 UIKit 0x0000000103db5cea -[UIKeyboardImpl handleKeyCommand:repeatOkay:beforePublicKeyCommands:] + 4884 19 UIKit 0x0000000103dd26ce -[UIKeyboardImpl handleKeyEvent:executionContext:] + 1166 20 UIKit 0x0000000104832bd3 -[UIKeyboardTaskEntry execute:] + 164 21 UIKit 0x00000001048313dd -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 374 22 UIKit 0x0000000103dd21af -[UIKeyboardImpl handleKeyEvent:] + 210 23 CoreFoundation 0x00000001035bbccc __invoking___ + 140 24 CoreFoundation 0x00000001035bbb84 -[NSInvocation invoke] + 308 25 UIKit 0x00000001043f2cad -[UIRepeatedAction invoke] + 293 26 UIKit 0x00000001043f2ce3 -[UIRepeatedAction _preInvocationTimerFire] + 22 27 UIKit 0x0000000103ad1614 -[UIApplication _handleKeyUIEvent:] + 2050 28 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 29 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 30 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 31 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 32 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 33 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 34 UIKit 0x0000000103ce4cdb -[UIResponder _handleKeyUIEvent:] + 79 35 UIKit 0x0000000103ad0b3c -[UIApplication handleKeyUIEvent:] + 103 36 UIKit 0x0000000103ad0ab5 -[UIApplication handleKeyHIDEvent:] + 692 37 UIKit 0x0000000104410fa8 __dispatchPreprocessedEventFromEventQueue + 997 38 UIKit 0x00000001044142c4 __handleEventQueueInternal + 5949 39 CoreFoundation 0x00000001035dabb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 40 CoreFoundation 0x00000001035bf4af __CFRunLoopDoSources0 + 271 41 CoreFoundation 0x00000001035bea6f __CFRunLoopRun + 1263 42 CoreFoundation 0x00000001035be30b CFRunLoopRunSpecific + 635 43 GraphicsServices 0x000000010988ea73 GSEventRunModal + 62 44 UIKit 0x0000000103ab5057 UIApplicationMain + 159 45 SchoolDrive 0x0000000100fce117 main + 55 46 libdyld.dylib 0x000000010679f955 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:1)
[SchoolDrive.SecondRegisterViewController用户名文本:]:无法识别 选择器发送到实例0x7ffc57c2e840 2018-07-29 06:50:33.321943 + 0530 SchoolDrive [22497:4253058] * 到期的应用到期 未捕获异常“ NSInvalidArgumentException”,原因: '-[SchoolDrive.SecondRegisterViewController用户名文本:]: 无法识别的选择器已发送到实例 0x7ffc57c2e840'
在处理布局时,无法识别的选择器通常意味着您连接IBOutlet的方式存在问题。在这种情况下,您要么尝试使用尚未连接的视图,要么更有可能是因为您说过已连接所有插座,所以连接了两次/不应该连接到那里。做任何一个都会引起问题。
尝试按ctrl键并单击所有视图,然后查看它们的连接-可能会发现问题。
如果一切都检查了,请尝试删除所有连接并重做它们。如果那不起作用,请回来告诉我们您已经排除了该问题。
编辑:由于错误消息指定了UsernameText,因此错误可能出在这里,但检查其余部分不会受到损害。
答案 1 :(得分:0)
您应该尝试删除并重新添加SecondRegisterViewController viewConteoller的类。
执行以下步骤。