Button 一些小筆記.
@IBAction func showAlertControll_actionsheet(){
//建立控制項
let alterController = UIAlertController(title: "提示訊息", message: "Im AlertController.actionsheet", preferredStyle: UIAlertControllerStyle.actionSheet)
//建立選項
alterController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
//顯示於螢幕上
self.present(alterController, animated: true, completion: nil)
}
@IBAction func showAlertControll_alert(){
let alterController = UIAlertController(title: "警告訊息", message: "Im AlertController.alert", preferredStyle: UIAlertControllerStyle.alert)
alterController.addAction(UIAlertAction(title: "Delete", style: UIAlertActionStyle.destructive, handler: nil))
self.present(alterController, animated: true, completion: nil)
}
@IBAction func showAlertControll(){
//UIAlertControllerStytle.init(rawValue) ,rawValue: 0 = actionsheet, rawValue: 1 = alert
let alterController = UIAlertController(title: "提示訊息", message: "Im rawValue: 0", preferredStyle: (UIAlertControllerStyle.init(rawValue: 0))!)
let callAction = UIAlertAction(title: "Title", style: UIAlertActionStyle.default, handler: nil)
print("Title")
alterController.addAction(callAction)
self.present(alterController, animated: true, completion: nil)
}
@IBAction func showAlertControllWithNoSelectButton(){
//沒有做選項會卡在螢幕上不能動
let alertController = UIAlertController(title: "警告訊息", message: "我沒有按鈕選項", preferredStyle: UIAlertControllerStyle.alert)
self.present(alertController, animated: true, completion: nil)
}