swift - 使用 Swift 在 Web View 中点击电话号码时显示警报 View

标签 swift

我有一个 WebView ,显示公司的地址、电话号码和电子邮件。当前的行为是,当点击电话号码时,会立即调用。

有没有办法提示警报 View 让用户确认调用?而不是立即调用它?

最佳答案

这是我用来初始化警报的函数:

 func displayAlert(title: String, message: String) {
    var alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (ACTION) -> Void in
        // self.dismissViewControllerAnimated(true, completion: nil)
        alert.hidesBottomBarWhenPushed = true
    }))
    print("running Activityindicator code")
    self.presentViewController(alert, animated: true, completion: nil)
}

我这样调用它:

self.displayAlert("Alert title", message: "alert message")

希望这有帮助!

关于swift - 使用 Swift 在 Web View 中点击电话号码时显示警报 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32622523/

相关文章:

ios - 初始化的枚举返回错误的 hashValue

swift - 使用执行(afterDelay :) within a while loop gives me a logic error?

ios - 如何从单个tableViewcell中获取多个按钮?

swift - 在 MacOS 上使用 swift 3 在登录钥匙串(keychain)中安装证书

使用 Swift 时提前释放 Objective-C 变量

ios - swift 5 : Why is my data within struct suddenly empty/nil?

swift - 我收到错误 Expression was too complex to be solved in a reasonable time;考虑将表达式分解为不同的子表达式

ios - 使用核心运动检测 iPhone 是否抛向空中

swift - 'value' 的使用不明确

ios - 在不使用 CAShapeLayer 的情况下对 UIBezierPath 的笔划进行划线并为该笔划设置动画