小编mot*_*teb的帖子

UIActionSheet与swift

我创建了一个操作表,但问题是没有调用委托方法

 myActionSheet = UIActionSheet()
        myActionSheet.addButtonWithTitle("Add event")
        myActionSheet.addButtonWithTitle("close")
        myActionSheet.cancelButtonIndex = 1
        myActionSheet.showInView(self.view)
Run Code Online (Sandbox Code Playgroud)

/// UIActionSheetDelegate

func actionSheet(myActionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){
        if(myActionSheet.tag == 1){

            if (buttonIndex == 0){
                println("the index is 0")
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

我使用了另一种适用于iOS 8的方法但不适用于iOS 7:

var ActionSheet =  UIAlertController(title: "Add View", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet)

ActionSheet.addAction(UIAlertAction(title: "Add event", style: UIAlertActionStyle.Default, handler:nil))

self.presentViewController(ActionSheet, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

有什么想法解决这个问题吗?

uiactionsheet ios7 swift ios8

10
推荐指数
3
解决办法
2万
查看次数

标签 统计

ios7 ×1

ios8 ×1

swift ×1

uiactionsheet ×1