UIActionSheet
introduced=2.0, deprecated=8.3 早已废弃 还是拥抱 UIAlertController 吧
创建UIActionSheet
let actionSheel = UIActionSheet() actionSheel.addButtonWithTitle("取消") actionSheel.addButtonWithTitle("选项一") actionSheel.addButtonWithTitle("选项二") actionSheel.cancelButtonIndex = 0 actionSheel.delegate = self actionSheel.showInView(self.view)
实现代理 先遵守协议 UIActionSheetDelegate
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) { print(actionSheet.buttonTitleAtIndex(buttonIndex)!) if buttonIndex == actionSheet.cancelButtonIndex{ print("取消了!") }else{ print("都说了已经废弃了!!!") } }