1.新建actionSheet
var actionSheet = UIActionSheet (title: "title", delegate: self, cancelButtonTitle: "取消", destructiveButtonTitle: "登出", otherButtonTitles: "在等一下", "等一次")
actionSheet.showInView(self.view)
2.遵守协议
class RootViewController: UIViewController,UIActionSheetDelegate { //协议
3.回调函数
func actionSheetCancel(actionSheet: UIActionSheet) {// 点击取消按钮回调函数
}
func actionSheet(actionSheet: UIActionSheet, willDismissWithButtonIndex buttonIndex: Int) {
// 将要消失回调函数
}
func actionSheet(actionSheet: UIActionSheet, didDismissWithButtonIndex buttonIndex: Int) {
// 已经消失回调函数
}
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
// 点击按钮回调函数 返回的是按钮的索引值
}
本文介绍了如何在Swift中创建actionSheet,并通过遵守协议和设置回调函数来实现功能交互。
4561

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



