UIActionSheet with swift

后端 未结 5 1265
清酒与你
清酒与你 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:34

    UIActionSheet is deprecated since iOS8, I would recommend using UIAlertController if you don't have to support version below:

    private func presentSettingsActionSheet() {
      let settingsActionSheet: UIAlertController = UIAlertController(title:nil, message:nil, preferredStyle:UIAlertControllerStyle.ActionSheet)
      settingsActionSheet.addAction(UIAlertAction(title:"Send Feedback", style:UIAlertActionStyle.Default, handler:{ action in
        self.presentFeedbackForm()
      }))
      settingsActionSheet.addAction(UIAlertAction(title:"Tell Me a Joke!", style:UIAlertActionStyle.Default, handler:{ action in
        self.presentRandomJoke()
      }))
      settingsActionSheet.addAction(UIAlertAction(title:"Cancel", style:UIAlertActionStyle.Cancel, handler:nil))
      presentViewController(settingsActionSheet, animated:true, completion:nil)
    }
    

    Here is what it looks like presented:

                                         AlertViewController in Swift

提交回复
热议问题