【发布时间】:2017-11-04 12:07:12
【问题描述】:
我在 uiAlertController 中有一个文本字段,我想检索其中的内容来构建一个对象。我写了以下代码:
let alertController = UIAlertController(title: "Ajouter une description", message: "De quoi sagit il ?", preferredStyle: UIAlertControllerStyle.alert)
alertController.addTextField { (textField : UITextField) -> Void in
textField.placeholder = "Description"
self.theDescription = textField.text!
}
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in
self.createArtWithDescription(description: self.theDescription)
}
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
//
}
为了构建我的对象,我有另一个函数“createArtWithDescription”,但在里面我无法检索 uiAlertController 文本字段的内容。
提前致谢
【问题讨论】:
-
这能回答你的问题吗? Access input from UIAlertController
标签: swift textfield uialertcontroller