Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.58 KB

UIAlertController.md

File metadata and controls

54 lines (36 loc) · 1.58 KB

UIAlertController

Basics

import UIKit

class ViewController: UIViewController {
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        showAlert()
    }

    func showAlert() {
        let alert = UIAlertController(title: "Notifications Disabled",
                                      message: "For the best chat experience needs notification",
                                      preferredStyle: .alert)

        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
        alert.addAction(UIAlertAction(title: "Settings", style: .cancel, handler: nil))

        present(alert, animated: true, completion: nil)
    }
}

TableView

TableView

TableView

How to programmatically dismiss

if let _ = presentedViewController as? UIAlertController {
    dismiss(animated: true, completion: nil)
}

Number of buttons

  • One or two buttons will be placed side-by-side.

  • Three buttons or more it will want to stack.

Links that help