T
T
tiger_132019-09-18 06:58:08
iOS
tiger_13, 2019-09-18 06:58:08

What is this element called in swift?

Tell me, please, what is the name of this element (buttons that appear at the bottom) in swift, and how to call them in the code?
5d81ab4c53c98649862476.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iMaximus, 2019-09-18
@tiger_13

Previously, UIActionSheet is now UIActionController, if I'm not mistaken, but there you can do whatever you want. Buttons or whatever.

A
Aleksandr Govorukhin, 2019-09-23
@SnapSh0t

1*nUOQv3AjroYhqdfnMTj-pA.jpeg

func showSimpleAlert() {
        let alert = UIAlertController(title: "Sign out?", message: "You can always access your content by signing back in",         preferredStyle: UIAlertControllerStyle.alert)

        alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default, handler: { _ in
            //Cancel Action
        }))
        alert.addAction(UIAlertAction(title: "Sign out",
                                      style: UIAlertActionStyle.default,
                                      handler: {(_: UIAlertAction!) in
                                        //Sign out action
        }))
        self.present(alert, animated: true, completion: nil)
    }

func showSimpleActionSheet(controller: UIViewController) {
        let alert = UIAlertController(title: "Title", message: "Please Select an Option", preferredStyle: .actionSheet)
        alert.addAction(UIAlertAction(title: "Approve", style: .default, handler: { (_) in
            print("User click Approve button")
        }))

        alert.addAction(UIAlertAction(title: "Edit", style: .default, handler: { (_) in
            print("User click Edit button")
        }))

        alert.addAction(UIAlertAction(title: "Delete", style: .destructive, handler: { (_) in
            print("User click Delete button")
        }))

        alert.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler: { (_) in
            print("User click Dismiss button")
        }))

        self.present(alert, animated: true, completion: {
            print("completion block")
        })
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question