Quantcast
Channel: How to create an alert box in iphone? - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by Shaba Aafreen for How to create an alert box in iphone?

$
0
0

For swift it is very simple.

    //Creating the alert controller
    //It takes the title and the alert message and prefferred style
    let alertController = UIAlertController(title: "Hello  Coders", message: "Visit www.simplifiedios.net to learn xcode", preferredStyle: .Alert)

    //then we create a default action for the alert... 
    //It is actually a button and we have given the button text style and handler
    //currently handler is nil as we are not specifying any handler
    let defaultAction = UIAlertAction(title: "Close Alert", style: .Default, handler: nil)

    //now we are adding the default action to our alertcontroller
    alertController.addAction(defaultAction)

    //and finally presenting our alert using this method
    presentViewController(alertController, animated: true, completion: nil)

Ref: iOS Show Alert Message


Viewing all articles
Browse latest Browse all 11

Trending Articles