simple alert swifti

class ViewController: UIViewController {

    @IBAction func showAlertButtonTapped(_ sender: UIButton) {

        // create the alert
        let alert = UIAlertController(title: "My Title", message: "This is my message.", preferredStyle: .alert)

        // add an action (button)
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))

        // show the alert
        self.present(alert, animated: true, completion: nil)
    }
}

3.5
2

                                    struct ContentView: View {
    @State private var showingAlert = false

    var body: some View {
        Button("Show Alert") {
            showingAlert = true
        }
        .alert("Important message", isPresented: $showingAlert) {
            Button("OK", role: .cancel) { }
        }
    }
}

3.5 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
swiftui alert example alert swift ui how to create custom alert view in swift code alert in swiftui swift alert types simple alert swifti swift 5 custom alert custom alert view in swift Alert with action in swiftui show alert message in swiftui custom alerts swift swift alertview custom how to make alert in swift alert with action swift alert controller swift how to show alert swift show alert from swift Swift alert callback ios swiftui alert messages alert with action in swift alert in swift design swift present alert alert swiftui alert in swift display alert message swift ui Swift alerte swift ui custom Alert how to make custom alert in swiftui swiftui alert messages custom alert view swift custom alert in swiftui swiftui show alert swift callback for alert swift alert frameworks alert swiftUI custome alert swift how to use alert in swiftui swift ui alert swiftui custom alert show alert swiftui ios how tio use alertviewcontrollewr in swift how to place alerts in swiftui swift alert from model add in alert swift swift system alert show an alert swiftUI show an alert swift UI show alert in swift Most uses alert in swift how to create alert buttons in swift swift ios alert swift custom alert view in swift alert action in swift simple alert swiftui showing alert in swift alert controller in swift display alert in swift ios show alert dialog swift show message show alert controller swift alert controller in swift s present alert swiftui show alert before going to next view controller swift 5 swift make alert uialert control ios how to show a prompt on screen xcode swift alert function alert without title and message swift code how to make alert swift uialertcontroller yes no uialertview swift alert vie show alert fromswift swift alert box swift uialert ios single choice alert view controller in swift swift 5 popup alert add label info swift 5 popup alert how to use alert popup box in swift swiftui alert alert completion swift alertcontroller swift 5 aleartcontroller in swift 5 swift create alert pop up message in swift throw different alert in two iphones for same action ios swift add alert in view swift swift alert handler swift ios afer alert alert in swift ios alert with message in swift ios swift display alertdialog swift simple alert alert in swift 3 message box swift how to send alert to user swift how to alert in xcode alertview controller in swift ios alertbox with action swift swift uialert normal alery function with message swift 5 swift pop up alert how to create a uialertcontroller in swift swift alert completion swift add alert uialertviewcontroller swift shopw alert ios swift display alert dialog swift swift pop up with action alert view controller swift alert ok or error swift pop alert swift message box swift action dialog swift show alert with completion handler creating quick alerts using swift in xcode alert in ios swift alert modal making an alert sreen in swift alert swift swift prompt alert show alert view controller swift alert in swift 5 ios alert swift xcode create alert alert view controller in swift 5 action after alert button click swift uialert modal swift programmatic alert in swift swift best way to handle alerts present alert swift how to style alert box in swift select alert swift choose alert swift swift show alert dialog swift alert tutorial swift 5 pop up alert pop up choose one from difference choices swift 5 swift alert action alert in swift ios alert dialog swift swift message popup how to show alert swift 5 swift alert view ios kCFErrorDomainCFNetwork swift show alert how to create a dialog swift 5 show dialog swift 5 alert action type in swift alert message in swift 5 lalert for swift alert styles swift create alert swift show alert swift swift show alert xcode simulator show alert send an alert dialog ios alert action in swift 5 alert swift 5 swift alerts alert from an alert swift ios swift 5 alert alert message swift swift alert UI ALERT swift 5 uialert swift alert for swift xcode alert popup how to present an alert to view controler swift alert view swift uialertcontroller present style in swift4 swift 4 alert show dialog alert in swift swift alert message ios swift 5 show alert dialog uialertcontroller alaert types swift show alert with button how to figure out where an alert dialog is from swift xcode uialertcontroller swift 5 create alert in swift ios how to make an alert swift screen alert swift
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source