【发布时间】:2015-05-13 19:58:14
【问题描述】:
如何捕获返回键按下并为警报内的文本字段执行操作? 这是警报的代码:
var alert = UIAlertController(title: "Add Country", message: "Add a country to the Speaker's List", preferredStyle: .Alert)
let saveAction = UIAlertAction(title: "Save", style: .Default) {
(action: UIAlertAction!) -> Void in
let textField = alert.textFields![0] as! UITextField
self.countries.append(textField.text)
self.speakersListTableView.reloadData()
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Default) {
(action: UIAlertAction!) -> Void in
}
alert.addTextFieldWithConfigurationHandler {
(textField: UITextField!) -> Void in
}
alert.addAction(saveAction)
alert.addAction(cancelAction)
【问题讨论】: