【发布时间】:2014-08-19 22:01:34
【问题描述】:
我有一个带有文本字段和两个按钮的 AlertController:CANCEL 和 SAVE。这是代码:
@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 的图片应用程序一样。请有人可以解释我该怎么做?
【问题讨论】:
标签: ios swift alert uialertcontroller