【问题标题】:Swift UIAlertController with url in text带有文本 url 的 Swift UIAlertController
【发布时间】:2018-04-10 12:57:46
【问题描述】:

我有这个代码:

func alertBox(txt: String){
        let ac = UIAlertController(title: "MyTtle" , message: "More information in my website: ", preferredStyle: .alert)
        let ramkaNaObrazek = CGRect(origin: CGPoint(x: 10, y: 10), size: CGSize(width: 30, height: 30))
        let ikonaAlertu = UIImageView(frame: ramkaNaObrazek)
        ikonaAlertu.image = UIImage(named: "modal_podpowiedz")
        ac.view.addSubview(ikonaAlertu)
        ac.addAction(UIAlertAction(title: "Ok" , style: .cancel, handler: { (action: UIAlertAction!) in
        }))
        present(ac, animated: true)
    }

我想在此文本之后添加:“我的网站中的更多信息:”+ www - 指向我的网站的链接 (http://www.myname.pl)。

我该怎么做?

【问题讨论】:

  • 尝试使用this
  • 您希望此链接可点击吗?在这种情况下,您应该添加一个操作按钮来加载您的网站
  • 你想在确定按钮上点击打开链接吗?
  • 不,我想在点击标签/文字后打开浏览器:“myname.pl
  • 我想知道您需要为此使用自定义警报框。如果你愿意,我可以为你提供使用 OK 按钮打开 URL 的代码

标签: ios swift uialertcontroller


【解决方案1】:

您不能将自定义字段(如带有可点击链接的文本视图)添加到UIAlertController。您需要创建自己的模态视图控制器,其行为类似于UIAlertController,或者使用第三方框架为您完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多