既然你已经为你的班级做了一个UITextFieldDelegate广告这个功能
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { let text = (textField.text as NSString).stringByReplacingCharactersInRange(range, withString: string) if !text.isEmpty{ continueButton.userInteractionEnabled = true } else { continueButton.userInteractionEnabled = false } return true }
还会更新您的viewDidLoad函数
override func viewDidLoad() { super.viewDidLoad() nounTextField.delegate = self if nounTextField.text.isEmpty{ continueButton.userInteractionEnabled = false } }