swift开发之UIAlertController

作者:new 分类: iOS应用开发 发布于:2016-10-20 6:24 ė次浏览 6条评论

UIAlertController集合了AlertView和ActionSheet

Alert:


        

let msgBox:UIAlertController = UIAlertController(title: "Tips", message: "Select "+account_name_arr[indexPath.row], preferredStyle: UIAlertControllerStyle.Alert);
        msgBox.addAction(UIAlertAction(title: "OK", style: .Default, handler: {(action:UIAlertAction)->Void in
            print("->OK")
        }))
msgBox.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: {(action:UIAlertAction)->Void in        
        msgBox.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: {(action:UIAlertAction)->Void in
            print("->Cancel")
        }))
self.presentViewController(msgBox, animated: true, completion: nil)  



ActionSheet:


        

let choose_ac:UIAlertController = UIAlertController(title: "提示", message: "添加类型", preferredStyle: .ActionSheet)
        choose_ac.addAction(UIAlertAction(title: "账号", style: UIAlertActionStyle.Default, handler: {(action:UIAlertAction)->Void in
            print("->OK1")
            self.initData()
        }))
        choose_ac.addAction(UIAlertAction(title: "银行卡", style: UIAlertActionStyle.Default, handler: {(action:UIAlertAction)->Void in
            print("->OK2")
        }))
        choose_ac.addAction(UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel, handler: {(action:UIAlertAction)->Void in
            print("->OK2")
        }))
        self.presentViewController(choose_ac, animated: true, completion: nil)



本文出自 码农,转载时请注明出处及相应链接。

0

发表评论

电子邮件地址不会被公开。必填项已用*标注


Ɣ回顶部