swift - 如何将 url 添加到警报?

标签 swift nsurl uialertcontroller

有没有办法为寻找更多信息的用户添加 url?我的警报看起来像这样

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)

想法是将它们重定向到网页并关闭应用程序中的 UIAlertController

最佳答案

您不能向 UIAlertController 添加任意接口(interface)。标题和消息不可点击。您无法添加更多文本。相反,添加另一个按钮 (UIAlertAction) 将它们引导至网页。或者,或者使用其他一些接口(interface)而不是 UIAlertController(例如,您可以放置​​一个呈现的 View Controller ,它看起来像一个警报)。

关于swift - 如何将 url 添加到警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39438417/

相关文章:

ios - UIActionSheet/UIAlertController 多行文本

ios - 尝试在 UINavigationController 上呈现 UIAlertController,其 View 不在窗口层次结构中

ios - 在应用程序委托(delegate)中显示警报的方法失败,因为它的 rootViewController 不在 View 层次结构中

ios - Swift:If let 语句无法处理空数组

ios - 如何将 indexPath(不是 indexPath.row)传递到我的 UITableViewCell 的 IBAction

swift - NSURL 没有在我的项目中找到我的视频

ios - POST 请求没有收到所有的 json

ios - 如何在Xcode中正确设置UIButton的约束(如图)?

ios - 为什么我无法将字符串变量转换为整数值?

ios - 字符串中奇怪的不可见字符导致 NSURL 失败