How do you make a UITextView detect link part in the text and still have userInteractionDisabled?

前端 未结 3 954
遇见更好的自我
遇见更好的自我 2020-12-19 03:08

I have a textView that is layered on a tableView cell. I need the user to click on the tableView row to open a viewController but if the textView has a link it must be click

3条回答
  •  醉酒成梦
    2020-12-19 03:47

    Maybe it will be ok for your purposes:

    textView.editable=NO;
    textView.userInteractionEnabled=YES;
    textView.dataDetectorTypes =UIDataDetectorTypeLink;
    

    But in fact UITextView uses UIWebView parts internally, and this way may be slowly in table cells. enter image description here

    I can advice to use CoreText or NSAttributedString's with touches. For example you may read this SO post.

提交回复
热议问题