我试着简单地调用一个名为“GoToNewShoot”的函数当用户按下“确定”按钮时,警告弹出谢谢!。
代码:
@IBAction func GobacktoCamera(sender: AnyObject) {
var alertController = UIAlertController(title: "Just Checking", message: "Are You Sure You Want to Start over ", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
答案 0 :(得分:21)
你可以通过这种方式使用addAction
处理程序来实现:
@IBAction func GobacktoCamera(sender: AnyObject) {
var alertController = UIAlertController(title: "Just Checking", message: "Are You Sure You Want to Start over", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Yes", style: .Default, handler: { action in
//run your function here
self.GoToNewShoot()
}))
self.presentViewController(alertController, animated: true, completion: nil)
}
func GoToNewShoot(){
println("Method Called")
}
答案 1 :(得分:0)
CREATE TABLE Item
(
ID INT auto_increment,
ItemCode VARCHAR(10) unique NOT NULL,
ItemDescription VARCHAR(50),
Price DECIMAL(4,2) DEFAULT 0,
PRIMARY KEY(ID)
);