我有一个带有文本字段和两个按钮(CANCEL和SAVE)的AlertController。这是代码:
@IBAction func addTherapy(sender: AnyObject)
{
let addAlertView = UIAlertController(title: "New Prescription", message: "Insert a name for this prescription", preferredStyle: UIAlertControllerStyle.Alert)
addAlertView.addAction(UIAlertAction(title: "Cancel",
style: UIAlertActionStyle.Default,
handler: nil))
addAlertView.addAction(UIAlertAction(title: "Save",
style: UIAlertActionStyle.Default,
handler: nil))
addAlertView.addTextFieldWithConfigurationHandler({textField in textField.placeholder = "Title"})
self.presentViewController(addAlertView, animated: true, completion: nil)
}
我想做的是在文本框上实现一个检查,当文本框为空时禁用“保存”按钮,就像iOS的Pictures应用程序创建新相册时那样。请问有人能告诉我该怎么做吗?
actionToEnable
变量的定义。 - Maxi Mus#selector(self.textChanged(_:))
不再像以前那样工作,它只会给出一个错误(Type 'MyClass' has no member 'textChanged'
)- 是的,该函数确实存在。我尝试了这里建议的所有版本,但都没有起作用。 - Neph