Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a url to an alert?

Is there a method to add an url for users looking for additional information? My alert looks like this

let alert = UIAlertController(title: "Alert details", message: "For more detailed information, click the link below", preferredStyle: UIAlertControllerStyle.Alert)
    // add url here
    let okayAction = UIAlertAction(title: "Ok", style: .Default) { (action) in
        print(action)
    }
    alert.addAction(okayAction)

The idea is to redirect them to a webpage and close the UIAlertController in the app

like image 217
Shane O'Seasnain Avatar asked Jan 06 '23 09:01

Shane O'Seasnain


1 Answers

You cannot add arbitrary interface to a UIAlertController. The title and message are not tappable. You cannot add further text. Instead, add another button (UIAlertAction) that directs them to the Web page. Either that, or use some other interface instead of a UIAlertController (for example, you can put up a presented view controller that looks like an alert).

like image 114
matt Avatar answered Jan 11 '23 17:01

matt