swift开发之UIAlertController
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)
本文出自 码农,转载时请注明出处及相应链接。
发表评论