Cod*_*der 7 xcode segue swift uialertcontroller
我能够为我的按钮编写一个UIAlertController,它工作正常,但是当我按下YES或OK按钮时,我不知道如何切换到不同的页面.目前,YES或OK按钮无处可去.
@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)
}
}
Run Code Online (Sandbox Code Playgroud)
小智 15
您可以在故事板中创建一个segue,控制从场景顶部的黄色视图控制器拖动到新的视图控制器.然后在检查器中为该segue指定一个标识符.您可以从代码中的处理程序中调用它.
alert.addAction(UIAlertAction(title:"OK", style: .Default, handler: { action in self.performSegueWithIdentifier("mySegueIdentifier", sender: self) }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11599 次 |
| 最近记录: |