iOS 8 废弃了UIActionSheet, 现在使用UIAlertController
// actionSheet 样式的AlertController
let actionSheet = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.actionSheet)
// 添加一个Button
let someButton = UIAlertAction(title: "Button", style: UIAlertActionStyle.default) { (alert) -> Void in
//do something
}
// 取消
let cacelButton = UIAlertAction(title:"Cancel",style: UIAlertActionStyle.cancel, handler: nil)
actionSheet.addAction(someButton)
actionSheet.addAction(cancelButton)
// 在view controller的某个地方 present
self.present(actionSheet, animated: true, completion: nil)
本文介绍了在iOS8中如何使用UIAlertController替代废弃的UIActionSheet。通过实例演示了如何创建不同样式类型的UIAlertController,并添加按钮及取消选项。
281

被折叠的 条评论
为什么被折叠?



