问题
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
回答1:
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).
来源:https://stackoverflow.com/questions/39438417/how-can-i-add-a-url-to-an-alert