swift开发之UIAlertController
时间:2016-10-20 作者:new 分类: iOS应用开发
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)