Can't make URL clickable in UITextView

后端 未结 3 1725
逝去的感伤
逝去的感伤 2021-01-17 09:45

I\'m using Interface Builder to layout my app. I have a UITextView that contains some text, part of which is a URL that I\'d like to make clickable (e.g. launches a browser

相关标签:
3条回答
  • 2021-01-17 09:51

    Try to use this Hope this help to you

    Links are not clickable by default in a UITextView. But luckily they can be enabled with a few simple lines of code:

    self.review.editable = NO;//required
    self.review.selectable = YES;//required
    self.review.dataDetectorTypes = UIDataDetectorTypeLink;
    

    Unfortunately you cannot have an editable UITextView with clickable links. If you set editable to YES, then all links will be treated as regular text.

    EDIT

    Have u check properly it may be UITextview disable in your .xib file.

    0 讨论(0)
  • 2021-01-17 09:55

    The issue was that User Interaction Enabled wasn't checked at the bottom of the View section of IB's Attributes Inspector.

    0 讨论(0)
  • 2021-01-17 10:02

    Check the "Selectable" and "Links" checkboxes in the textview Attributes Inspector:

    enter image description here

    0 讨论(0)
提交回复
热议问题