<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=UIAlertController</id>
	<title>UIAlertController - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=UIAlertController"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;action=history"/>
	<updated>2026-05-07T00:32:42Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;diff=26499&amp;oldid=prev</id>
		<title>134.3.86.14 am 11. Januar 2023 um 12:35 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;diff=26499&amp;oldid=prev"/>
		<updated>2023-01-11T12:35:53Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 11. Januar 2023, 12:35 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Links ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; [[UIKit Framework]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Beispiele ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Beispiele ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In diesem Beispiel sind ein paar Alerts angelegt. Es gibt im View ein Label und ein paar Buttons. Interessant ist das CustomAlert. Es ist möglich vollständig eigene Designs  zu erzeugen. Am saubersten funktioniert das wenn man das Delegate Pattern nutzt.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In diesem Beispiel sind ein paar Alerts angelegt. Es gibt im View ein Label und ein paar Buttons. Interessant ist das CustomAlert. Es ist möglich vollständig eigene Designs  zu erzeugen. Am saubersten funktioniert das wenn man das Delegate Pattern nutzt.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>134.3.86.14</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;diff=26498&amp;oldid=prev</id>
		<title>134.3.86.14 am 11. Januar 2023 um 12:24 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;diff=26498&amp;oldid=prev"/>
		<updated>2023-01-11T12:24:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 11. Januar 2023, 12:24 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Beispiele ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Beispiele ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In diesem Beispiel sind ein paar Alerts angelegt. Es gibt im View ein Label und ein paar Buttons. Interessant ist das CustomAlert. Es ist möglich vollständig eigene Designs  zu erzeugen. Am saubersten funktioniert das wenn man das Delegate Pattern nutzt.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;//&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;//&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>134.3.86.14</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;diff=26497&amp;oldid=prev</id>
		<title>134.3.86.14: Die Seite wurde neu angelegt: „== Beispiele == &lt;syntaxhighlight lang=&quot;swift&quot;&gt; // //  ViewController.swift //  UIAlert Demo // //  Created by Stephan Schlegel on 08.01.23. //  import UIKit  c…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=UIAlertController&amp;diff=26497&amp;oldid=prev"/>
		<updated>2023-01-11T12:22:53Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „== Beispiele == &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt; // //  ViewController.swift //  UIAlert Demo // //  Created by Stephan Schlegel on 08.01.23. //  import UIKit  c…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Beispiele ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
//&lt;br /&gt;
//  ViewController.swift&lt;br /&gt;
//  UIAlert Demo&lt;br /&gt;
//&lt;br /&gt;
//  Created by Stephan Schlegel on 08.01.23.&lt;br /&gt;
//&lt;br /&gt;
&lt;br /&gt;
import UIKit&lt;br /&gt;
&lt;br /&gt;
class ViewController: UIViewController, CustomAlertDelegate {&lt;br /&gt;
    &lt;br /&gt;
    let customAlert = CustomAlert()&lt;br /&gt;
    &lt;br /&gt;
    @IBOutlet weak var label: UILabel!&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        customAlert.delegate = self // catch up delegate of custom alert&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    @IBAction func buttonTapped(_ sender: UIButton) {&lt;br /&gt;
        print(&amp;quot;Button \(sender.tag) tapped&amp;quot;)&lt;br /&gt;
        &lt;br /&gt;
        /**&lt;br /&gt;
         Note that showInput1 and showInput2 gives an Constraint Error in XCode 14&lt;br /&gt;
         when they open (maybe a bug as it&amp;#039;s the normal implementation.&lt;br /&gt;
         The customAlert gives none because of it&amp;#039;s&lt;br /&gt;
         translatesAutoresizingMaskIntoConstraints = false&lt;br /&gt;
         but this means it have to set it&amp;#039;s own constrains&lt;br /&gt;
         */&lt;br /&gt;
        if sender.tag == 1{&lt;br /&gt;
            showAlert()&lt;br /&gt;
        }else if sender.tag == 2{&lt;br /&gt;
            showSelection()&lt;br /&gt;
        }else if sender.tag == 3 {&lt;br /&gt;
            showInput1()&lt;br /&gt;
        }else if sender.tag == 4 {&lt;br /&gt;
            showInput2()&lt;br /&gt;
        }else if sender.tag == 5 {&lt;br /&gt;
            showCustomAlert()&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    func alertDidDismissWithInput(_ input: String?) {&lt;br /&gt;
        // Handle the input here&lt;br /&gt;
        if(input != nil){&lt;br /&gt;
            print(&amp;quot;user input: \(input ?? &amp;quot;&amp;quot;)&amp;quot;)&lt;br /&gt;
            label.text = &amp;quot;Your input: \(input ?? &amp;quot;&amp;quot;)&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private func showAlert(){&lt;br /&gt;
        let alertController = UIAlertController(title: &amp;quot;Error&amp;quot;, message: &amp;quot;Invalaid email address&amp;quot;, preferredStyle: .alert)&lt;br /&gt;
        let dismissAction = UIAlertAction.init(title: &amp;quot;Dismiss&amp;quot;, style: .default)&lt;br /&gt;
        alertController.addAction(dismissAction)&lt;br /&gt;
        present(alertController, animated: true, completion: nil)&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private func showSelection(){&lt;br /&gt;
        let alertController = UIAlertController(title: &amp;quot;Confirmation&amp;quot;, message: &amp;quot;Select an item&amp;quot;, preferredStyle: .alert)&lt;br /&gt;
        let appleAction = UIAlertAction(title: &amp;quot;Apple ????&amp;quot;, style: .default){ _ in&lt;br /&gt;
            self.label.text = &amp;quot;Eating apples ????&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
        let orangeAction = UIAlertAction(title: &amp;quot;Orange ????&amp;quot;, style: .default){ _ in&lt;br /&gt;
            self.label.text = &amp;quot;Eating an orange ????&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
        let cherryAction = UIAlertAction(title: &amp;quot;Cherry ????&amp;quot;, style: .default){ _ in&lt;br /&gt;
            self.label.text = &amp;quot;Eating cherries ????&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
        alertController.addAction(appleAction)&lt;br /&gt;
        alertController.addAction(orangeAction)&lt;br /&gt;
        alertController.addAction(cherryAction)&lt;br /&gt;
        present(alertController,animated: true,completion: {&lt;br /&gt;
            print(&amp;quot;selection done&amp;quot;)&lt;br /&gt;
        })&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private func showInput1(){&lt;br /&gt;
        let alertController = UIAlertController(title: &amp;quot;Text-Eingabe&amp;quot;, message: &amp;quot;Gib deinen Namen ein:&amp;quot;, preferredStyle: .alert)&lt;br /&gt;
        // add text field&lt;br /&gt;
        alertController.addTextField { (textField) in&lt;br /&gt;
            textField.placeholder = &amp;quot;Name&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
        let okAction = UIAlertAction(title: &amp;quot;OK&amp;quot;, style: .default) { (action) in&lt;br /&gt;
            let name = alertController.textFields?[0].text&lt;br /&gt;
            print(&amp;quot;Dein Name ist: \(name ?? &amp;quot;na&amp;quot;)&amp;quot;)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        alertController.addAction(okAction)&lt;br /&gt;
&lt;br /&gt;
        present(alertController, animated: true, completion: nil)&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private func showInput2(){&lt;br /&gt;
        let alertController = UIAlertController(title: &amp;quot;Login&amp;quot;, message: &amp;quot;Enter name and password&amp;quot;, preferredStyle: .alert)&lt;br /&gt;
        alertController.addTextField(configurationHandler: nil)&lt;br /&gt;
        alertController.addTextField{ textField in&lt;br /&gt;
            textField.isSecureTextEntry = true&lt;br /&gt;
        }&lt;br /&gt;
        let okAction = UIAlertAction(title: &amp;quot;OK&amp;quot;, style: .default){ _ in&lt;br /&gt;
            var _name = String()&lt;br /&gt;
            var _password = String()&lt;br /&gt;
            &lt;br /&gt;
            if let nameTextField = alertController.textFields?.first,&lt;br /&gt;
               let name = nameTextField.text{&lt;br /&gt;
                    _name = name&lt;br /&gt;
            }&lt;br /&gt;
            if let passwordTextField = alertController.textFields?.last,&lt;br /&gt;
               let password = passwordTextField.text{&lt;br /&gt;
                    _password = password&lt;br /&gt;
            }&lt;br /&gt;
            self.label.text = _name + &amp;quot; &amp;quot; + _password&lt;br /&gt;
        }&lt;br /&gt;
        alertController.addAction(okAction)&lt;br /&gt;
        present(alertController, animated: true)&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private func showCustomAlert() {&lt;br /&gt;
        self.customAlert.alertTitle = &amp;quot;Custom Alert&amp;quot;&lt;br /&gt;
        present(self.customAlert, animated: true, completion: nil)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
//&lt;br /&gt;
//  CustomAlert.swift&lt;br /&gt;
//  UIAlert Demo&lt;br /&gt;
//&lt;br /&gt;
//  Created by Stephan Schlegel on 10.01.23.&lt;br /&gt;
//&lt;br /&gt;
&lt;br /&gt;
import UIKit&lt;br /&gt;
&lt;br /&gt;
// protocol for delegate pattern&lt;br /&gt;
protocol CustomAlertDelegate: AnyObject {&lt;br /&gt;
    func alertDidDismissWithInput(_ input: String?)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class CustomAlert: UIViewController {&lt;br /&gt;
    weak var delegate: CustomAlertDelegate?&lt;br /&gt;
    &lt;br /&gt;
    // Code for creating UI elements&lt;br /&gt;
    var alertTitle: String?&lt;br /&gt;
    var inputTextField: UITextField?&lt;br /&gt;
    var okButton: UIButton?&lt;br /&gt;
    var dismissButton: UIButton?&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        &lt;br /&gt;
        // Create the alert title label&lt;br /&gt;
        let titleLabel = UILabel()&lt;br /&gt;
        titleLabel.text = alertTitle&lt;br /&gt;
        titleLabel.textAlignment = .center&lt;br /&gt;
        titleLabel.translatesAutoresizingMaskIntoConstraints = false&lt;br /&gt;
        view.addSubview(titleLabel)&lt;br /&gt;
        &lt;br /&gt;
        // Create the text input field&lt;br /&gt;
        inputTextField = UITextField()&lt;br /&gt;
        inputTextField?.placeholder = &amp;quot;Enter some text&amp;quot;&lt;br /&gt;
        inputTextField?.borderStyle = .roundedRect&lt;br /&gt;
        inputTextField?.translatesAutoresizingMaskIntoConstraints = false&lt;br /&gt;
        view.addSubview(inputTextField!)&lt;br /&gt;
        &lt;br /&gt;
        // Create the &amp;quot;OK&amp;quot; button&lt;br /&gt;
        okButton = UIButton(type: .system)&lt;br /&gt;
        okButton?.backgroundColor = .systemFill&lt;br /&gt;
        okButton?.setTitleColor(.white, for: .normal)&lt;br /&gt;
        okButton?.setTitle(&amp;quot;OK&amp;quot;, for: .normal)&lt;br /&gt;
        okButton?.titleLabel?.textAlignment = .center&lt;br /&gt;
        okButton?.layer.borderWidth = 1&lt;br /&gt;
        okButton?.layer.borderColor = UIColor.black.cgColor&lt;br /&gt;
        okButton?.addTarget(self, action: #selector(okButtonTapped), for: .touchUpInside)&lt;br /&gt;
        okButton?.translatesAutoresizingMaskIntoConstraints = false&lt;br /&gt;
        //view.addSubview(okButton!)&lt;br /&gt;
        &lt;br /&gt;
        // Create the &amp;quot;Dismiss&amp;quot; button&lt;br /&gt;
        dismissButton = UIButton(type: .system)&lt;br /&gt;
        dismissButton?.backgroundColor = .systemFill&lt;br /&gt;
        dismissButton?.setTitleColor(.white, for: .normal)&lt;br /&gt;
        dismissButton?.setTitle(&amp;quot;Dismiss&amp;quot;, for: .normal)&lt;br /&gt;
        dismissButton?.titleLabel?.textAlignment = .center&lt;br /&gt;
        dismissButton?.layer.borderWidth = 1&lt;br /&gt;
        dismissButton?.layer.borderColor = UIColor.black.cgColor&lt;br /&gt;
        dismissButton?.addTarget(self, action: #selector(dismissButtonTapped), for: .touchUpInside)&lt;br /&gt;
        dismissButton?.translatesAutoresizingMaskIntoConstraints = false&lt;br /&gt;
        //view.addSubview(dismissButton!)&lt;br /&gt;
        &lt;br /&gt;
        // Create a stack view to hold the buttons&lt;br /&gt;
        let stackView = UIStackView(arrangedSubviews: [okButton!, dismissButton!])&lt;br /&gt;
        stackView.axis = .horizontal&lt;br /&gt;
        stackView.spacing = 20&lt;br /&gt;
        stackView.distribution = .fillEqually&lt;br /&gt;
        &lt;br /&gt;
        stackView.translatesAutoresizingMaskIntoConstraints = false&lt;br /&gt;
        view.addSubview(stackView)&lt;br /&gt;
        // Set the background color of the alert&lt;br /&gt;
        //view.backgroundColor = UIColor.lightGray&lt;br /&gt;
        &lt;br /&gt;
        // Add constraints to position the elements in the alert&lt;br /&gt;
        // constraint need to be add in detail&lt;br /&gt;
        let margins = view.layoutMarginsGuide&lt;br /&gt;
        &lt;br /&gt;
        NSLayoutConstraint.activate([&lt;br /&gt;
            titleLabel.topAnchor.constraint(equalTo: margins.topAnchor, constant: 20),&lt;br /&gt;
            titleLabel.leadingAnchor.constraint(equalTo: margins.leadingAnchor),&lt;br /&gt;
            titleLabel.trailingAnchor.constraint(equalTo: margins.trailingAnchor),&lt;br /&gt;
            &lt;br /&gt;
            inputTextField!.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 20),&lt;br /&gt;
            inputTextField!.leadingAnchor.constraint(equalTo: margins.leadingAnchor, constant: 20),&lt;br /&gt;
            inputTextField!.trailingAnchor.constraint(equalTo: margins.trailingAnchor, constant: -20),&lt;br /&gt;
            &lt;br /&gt;
            // Add constraints to position the stack view&lt;br /&gt;
            &lt;br /&gt;
            stackView.topAnchor.constraint(equalTo: inputTextField!.bottomAnchor, constant: 20),&lt;br /&gt;
            stackView.leadingAnchor.constraint(equalTo: margins.leadingAnchor, constant: 20),&lt;br /&gt;
            stackView.trailingAnchor.constraint(equalTo: margins.trailingAnchor, constant: -20)&lt;br /&gt;
        ])&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    @objc func okButtonTapped() {&lt;br /&gt;
        let input = inputTextField!.text&lt;br /&gt;
        delegate?.alertDidDismissWithInput(input)&lt;br /&gt;
        self.dismiss(animated: true, completion: nil) // close modal&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    @objc func dismissButtonTapped() {&lt;br /&gt;
        delegate?.alertDidDismissWithInput(nil)&lt;br /&gt;
        self.dismiss(animated: true, completion: nil) // close modal&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     when the user taps the &amp;quot;OK&amp;quot; button, the custom alert will pass the user input to the `alertDidDismissWithInput` method of the view controller by calling `delegate?.alertDidDismissWithInput(input)`.&lt;br /&gt;
     When user taps the &amp;quot;Dismiss&amp;quot; button, the custom alert will call `delegate?.alertDidDismissWithInput(nil)`  which will pass nil in the input parameter of the method and the view controller can handle this accordingly.&lt;br /&gt;
     &lt;br /&gt;
     This way by using delegation pattern, the view controller can handle the input separately from the presentation of the custom alert.&lt;br /&gt;
     */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>134.3.86.14</name></author>
	</entry>
</feed>