[objc] view plain copy //方法1 letalertSheet=UIActionSheet(Title:alertTitle,delegate:nil,cancelbuttonTitle:alertOK,0);background-color:inherit;">destructivebuttonTitle:alertCancel) alertSheet.showInVIEw(self.vIEw)
//方法2 //实例化时添加代理对象,同时注意添加协议 letalertSheet=UIActionSheet(Title:alertTitle,153);background-color:inherit;Font-weight:bold;">self,0);background-color:inherit;">destructivebuttonTitle:alertCancel,0);background-color:inherit;">otherbuttonTitles:"警告","提示","通告") alertSheet.showInVIEw(self.vIEw) //添加协议 classVIEwController:UIVIEwController,UIActionSheetDelegate{ overrIDefuncvIEwDIDLoad(){ ... } } //代理方法 //MARK:UIActionSheetDelegate funcactionSheet(actionSheet:UIActionSheet,clickedbuttonAtIndexbuttonIndex:Int){ letbuttonTitle=actionSheet.buttonTitleAtIndex(buttonIndex) ifbuttonTitle==alertCancel { print("你点击了退出") elseifbuttonTitle==alertOK print("你点击了确定") else print("你点击了其他") }
//方法3 //1实例化 letalertSheet=UIAlertController(Title:alertTitle,0);background-color:inherit;">message:alertMessage,0);background-color:inherit;">preferredStyle:UIAlertControllerStyle.ActionSheet) //2命令(样式:退出Cancel,警告Destructive-按钮标题为红色,默认Default) letcancelAction=UIAlertAction(Title:alertCancel,0);background-color:inherit;">style:UIAlertActionStyle.Cancel,0);background-color:inherit;">handler:nil) letdeleteAction=UIAlertAction(Title:"删除",0);background-color:inherit;">style:UIAlertActionStyle.Destructive,153);background-color:inherit;Font-weight:bold;">nil) letarchiveAction=UIAlertAction(Title:alertOK,0);background-color:inherit;">style:UIAlertActionStyle.Default,0);background-color:inherit;">handler:{ actionin print("OK") }) alertSheet.addAction(cancelAction) alertSheet.addAction(deleteAction) alertSheet.addAction(archiveAction) //3跳转 self.presentVIEwController(alertSheet,0);background-color:inherit;">animated:true,0);background-color:inherit;">completion:nil) 总结
以上是内存溢出为你收集整理的swift中UIActionSheet的使用全部内容,希望文章能够帮你解决swift中UIActionSheet的使用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)