[英]How do i stop my ios app from opening a url when user taps on any link in the app?
当我使用从api获取的数据填充它时,我想阻止我的应用打开可能出现在textview中的URL。
您可以使用以下代码:
textView.dataDetectorTypes = []
If you implement textView(_:shouldInteractWith:in:interaction:) of the UITextViewDelegate you can control whether the URL should be opened or not. 如果实现UITextViewDelegate的 textView(_:shouldInteractWith:in:interaction :) ,则可以控制是否应打开URL。
Just return false
if you don't want any URL to be handled: 如果您不希望处理任何URL,只需返回
false
:
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
return false
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.