Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

create alert in swift

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)
    }
}
Comment

alert swiftUI

@State private var showingAlert = false

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

simple alert swifti

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) { }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: how to select but not focus textfield swift 
Swift :: swift corner radious of view controller 
Swift :: Undefined symbol: protocol descriptor for Swift.ExpressibleByFloatLiteral 
Swift :: swift uibutton programmatically set ontap function 
Swift :: swift comments 
Swift :: array length swift 
Swift :: navigationController.pushViewController 
Swift :: swift 5 make a phone call 
Swift :: swiftui play mp3 
Swift :: Swift Properties 
Swift :: swift ways to setup constraints 
Swift :: power number in swift13 
Swift :: swift collectionview scrolltoitem 
Swift :: Thread 1: breakpoint 1.1 
Swift :: make preivew in dark mode swiftui 
Swift :: struct to json convert in swift 
Swift :: hex color swiftui 
Swift :: how to low case string swift 
Swift :: swift5 get uiview height 
Swift :: swift infinite while loop 
Swift :: record permission swift 4 
Swift :: how to show notification icon on tabbar item swift 
Swift :: uitextfield set max length 
Swift :: swift switch 
Swift :: The Swift pod `qr_code_scanner` depends upon `MTBBarcodeScanner`, which does not define modules 
Swift :: swift sf symbol uiimage size 
Swift :: check google ads sdk version swift 
Swift :: swift check if array has duplicates 
Swift :: Why Inheritance? 
Swift :: Swift Explicitly declaring an unwrapped optional 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =