【发布时间】:2015-06-09 21:03:03
【问题描述】:
以下代码是我编写的用于处理“返回”按钮和“注销”按钮的函数。当用户点击“取消”时,他将停留在当前视图上,当他点击“确定”时,他将被带到上一个视图或登录屏幕,具体取决于他点击的按钮。我可以用一个功能做到这一点,还是每个按钮都需要一个功能?我更喜欢一个可以创建全局函数并在所有三个视图中使用的函数。
func passThroughErrorAlertController(title:String, error:String) {
var passThroughAlert = UIAlertController(title: title, message: passThroughError, preferredStyle: UIAlertControllerStyle.Alert)
passThroughAlert.addAction((UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)))
passThroughAlert.addAction((UIAlertAction(title: "OK", style: .Default, handler: {action in
self.dismissViewControllerAnimated(true, completion: nil)
})))
self.presentViewController(passThroughAlert, animated: true, completion: nil)
}
我可以使用 performSegueWithIdentifier 然后使用带有 segue 标识符的 var 吗?那会是什么样子?我的意思是,在performSegueWithIdentifier 之后是否需要添加参数?
【问题讨论】:
标签: ios swift segue uialertcontroller