facebook twitter hatena line email

「Ios/swift/AlertView」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(確認メッセージ)
 
(同じ利用者による、間の4版が非表示)
行1: 行1:
==エラーメッセージ==
+
==通知メッセージ==
         let alert = UIAlertView(title: "エラー", message: "エラーです", delegate: self, cancelButtonTitle: "OK")
+
okのみ
         alert.show()
+
         let alert:UIAlertController = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: UIAlertControllerStyle.Alert)
 +
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {
 +
            (action) -> Void in
 +
            print("ok")
 +
         }))
 +
        self.presentViewController(alert, animated: true, completion: {})
  
 
==確認メッセージ==
 
==確認メッセージ==
 +
okとキャンセル
 
         let ac = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)
 
         let ac = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)
 
         let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) -> Void in
 
         let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) -> Void in
行13: 行19:
 
         ac.addAction(cancelAction)
 
         ac.addAction(cancelAction)
 
         ac.addAction(okAction)
 
         ac.addAction(okAction)
         presentViewController(ac, animated: true, completion: nil)
+
         self.presentViewController(ac, animated: true, completion: nil)
 
参考:http://qiita.com/osamu1203/items/f1aea7b932e69522f638
 
参考:http://qiita.com/osamu1203/items/f1aea7b932e69522f638

2016年8月2日 (火) 19:23時点における最新版

通知メッセージ

okのみ

       let alert:UIAlertController = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: UIAlertControllerStyle.Alert)
       alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {
           (action) -> Void in
           print("ok")
       }))
       self.presentViewController(alert, animated: true, completion: {})

確認メッセージ

okとキャンセル

       let ac = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)
       let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) -> Void in
           print("Cancel button tapped.")
       }
       let okAction = UIAlertAction(title: "OK", style: .Default) { (action) -> Void in
           print("OK button tapped.")
       }
       ac.addAction(cancelAction)
       ac.addAction(okAction)
       self.presentViewController(ac, animated: true, completion: nil)

参考:http://qiita.com/osamu1203/items/f1aea7b932e69522f638