如何使用 UITextview 在 ios swift 5 中进行调用?
How to make a call in ios swift 5 using UITextview?
我有编号为 phone 的 UITextView。 ios Swift 5.
UITextView中点击phone号码时如何拨打电话
TextView 提供一种委托方法来获取任何检测器的点击事件,例如 phone 数字,link。
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
if URL.scheme == "tel" {
let phone = URL.absoluteString.replacingOccurrences(of: "tel:", with: "")
if let callUrl = URL(string: "tel://\(phone)"), UIApplication.shared.canOpenURL(callUrl) {
UIApplication.shared.open(callUrl)
}
}
return true
}
还有这个别忘了
textView.dataDetectorTypes = [.phoneNumber]
textView.delegate = self
我有编号为 phone 的 UITextView。 ios Swift 5.
UITextView中点击phone号码时如何拨打电话TextView 提供一种委托方法来获取任何检测器的点击事件,例如 phone 数字,link。
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
if URL.scheme == "tel" {
let phone = URL.absoluteString.replacingOccurrences(of: "tel:", with: "")
if let callUrl = URL(string: "tel://\(phone)"), UIApplication.shared.canOpenURL(callUrl) {
UIApplication.shared.open(callUrl)
}
}
return true
}
还有这个别忘了
textView.dataDetectorTypes = [.phoneNumber]
textView.delegate = self