Swift 2.0 UIAlertView 和 UIActionSheet 的使用

时间:2021-02-23 04:58:32

在 IOS 9.0 之后, UIAlertView  是 给废弃了的,虽然你要使用的话,暂时还是可以的,但是在 9.0 之后,IOS 推荐大家使用的是  UIAlertController 这个控制器。下面是它的使用。

//  在 IOS 9.0 之后, UIAlertView  是 给废弃了的,虽然你要使用的话,暂时还是可以的,但是在 9.0 之后,IOS 推荐大家使用的是  UIAlertController 这个控制器。下面是它的使用。
let alview:UIAlertController = UIAlertController(title: "提示", message: "您点击了cell", preferredStyle: UIAlertControllerStyle.Alert) let action:UIAlertAction = UIAlertAction (title: "取消", style: UIAlertActionStyle.Cancel) { (action) -> Void in // 取消添加的点击事件
print("好想你")
} let actionOK:UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { (actionOK) -> Void in // OK 的点击事件
print("你还好吗")
} // 这里就是添加一个 事件 上去的感觉, 只是这个 事件 是有类型 ,比如 删除, 取消
alview .addAction(actionOK)
alview .addAction(action)
self .presentViewController(alview, animated: true) { () -> Void in }