尝试重新键盘时应用程序崩溃

时间:2015-03-30 16:09:54

标签: ios xcode swift

自从我更新到最新的Xcode 6测试版以来,我一直遇到关闭键盘的问题。每次我尝试关闭键盘时,我的应用程序都会崩溃,即使我已经使用了相同的代码,并且过去工作正常。

这就是我所拥有的:

@IBAction func viewTapped(sender : AnyObject) {
    //Closes keyboard when user touches screen.

    transactionDateInput.resignFirstResponder()
    transactionNameInput.resignFirstResponder()
    textField.resignFirstResponder()
    notesField.resignFirstResponder()

    UIView.animateWithDuration(1.5, animations: {
        self.valueEnter.alpha = 0
        self.dateEnter.alpha = 0
        self.notesDone.alpha = 0
        })
}

有人建议将其更改为:

if (transactionDateInput.isFirstResponder() == true){
     transactionDateInput.resignFirstResponder()
}

但这没有区别。有人有什么建议吗?这是错误:

AffordIt[4445:1334424] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AffordIt.SecondViewController textFieldShouldReturn:]: unrecognized selector sent to instance 0x7fb169666880'

1 个答案:

答案 0 :(得分:1)

检查文本字段出口委托(右键单击“文本字段”) 应该委托给你的UIViewController!

看看这个tutorial

相关问题