Hi I am trying to trigger separate click events for hyper link click and normal text click in UITextView
How to Separate hyperlink text click and and normal text click in UITextView
Hope you understand my problem.
Here is what I tried.
override func viewDidLoad() {
super.viewDidLoad()
let atributedHtmlText = """
Hey I dont have hyper link text so trigger func A(). Click <a href="http://www.google.com">I have hyper link so trigger func b here</a> for more information.
"""
testTV.setAttributedHtmlText(atributedHtmlText)
let tap = UITapGestureRecognizer(target: self, action: #selector(ViewController.tapFunction))
testTV.isUserInteractionEnabled = true
testTV.addGestureRecognizer(tap)
testTV.delegate = self
}
@objc func tapFunction(sender:UITapGestureRecognizer) {
print("tap working")
}
extension ViewController: UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL,
in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
print("URL Text Tapped ", URL)
return false
}
}