UIActionSheet with swift

后端 未结 5 1262
清酒与你
清酒与你 2021-02-20 15:07

I created an action sheet, but the problem is that the delegate method is not called

 myActionSheet = UIActionSheet()
        myActionSheet.addButtonWithTitle(\"         


        
5条回答
  •  天命终不由人
    2021-02-20 15:32

    Show Action sheet in Swift 4 / 5

        @IBAction func showActionSheet(sender: AnyObject) {
    
        let alert = UIAlertController(title: "Title", message: "Please Select an Option", preferredStyle: .actionSheet)
    
        
        alert.addAction(UIAlertAction(title: "Edit", style: .default , handler:{ (UIAlertAction)in
            print("User click Edit button")
        }))
    
        alert.addAction(UIAlertAction(title: "Delete", style: .destructive , handler:{ (UIAlertAction)in
            print("User click Delete button")
        }))
        
        alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler:{ (UIAlertAction)in
            print("User click Dismiss button")
        }))
    
    
        self.present(alert, animated: true, completion: {
            print("completion block")
        })
    }
    

提交回复
热议问题