【发布时间】:2015-02-18 18:49:33
【问题描述】:
我能够为我的按钮编写一个 UIAlertController,它工作正常,但我不知道如何在按下“是”或“确定”按钮后转到不同的页面。目前,“是”或“确定”按钮无处可去。
@IBAction func SubmitButton(sender: AnyObject) {
if a > 28.87 {
var alert = UIAlertController(title: "H4 with Guide Pins", message: "Can it be removed?", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "YES", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "NO", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
else if data2.text == "" {
var alert = UIAlertController(title: "Dimension", message: "Missing Data Input.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
else {
var alert = UIAlertController(title: "H4 with Guide Pins", message: "Enter Swallow Dimension.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
self.view.endEditing(true)
}
}
【问题讨论】:
-
如何实现处理程序而不是 nil
-
嗯...我以前从未使用过处理程序。我将如何编写该代码?
标签: xcode swift segue uialertcontroller