[swift] 複数の選択肢を持つalertViewを実装

複数の選択肢を持つalertViewを実装

let alert = UIAlertController(title:"Titie?",
                                  message: "Message",
                                  preferredStyle: UIAlertControllerStyle.Alert)
        
        
        let cancelAction:UIAlertAction = UIAlertAction(title: "Cancel",
                                                       style: UIAlertActionStyle.Cancel,
                                                       handler:{
                                                        action in
                                                        [キャンセルメソッドを書く]
        })
        let OKAction:UIAlertAction = UIAlertAction(title: "OK",
                                                   style: UIAlertActionStyle.Default,
                                                   handler:{
                                                    (action:UIAlertAction!) -> Void in
                                                    [実行メソッドを書く]
        })
        let OtherAction:UIAlertAction = UIAlertAction(title: "OK",
                                                   style: UIAlertActionStyle.Default,
                                                   handler:{
                                                    (action:UIAlertAction!) -> Void in
                                                    [実行メソッドを書く]
        })
        alert.addAction(cancelAction)
        alert.addAction(OKAction)
        alert.addAction(OtherAction)
        self.presentViewController(self.alert, animated: true, completion: nil)

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です