How can I add a url to an alert?

半世苍凉 提交于 2019-12-11 05:48:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!