search

Home  >  Q&A  >  body text

ios - 使用NSLinkAttributeName插入一段链接之后,接下来的输入都是链接的样式了,怎么去除?

我使用NSLinkAttributeName给textview插入了一个超链接。

insertString.addAttribute(NSLinkAttributeName, value: NSURL(string: textF1.text!)!, range: NSMakeRange(0, insertString.length))

但是这样的话,后来输入的text都变成了链接的样式
求问大神,如何在接下来的编辑中,取消超链接的样式。

怪我咯怪我咯2771 days ago520

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-18 09:43:36

    Looking at your code, the range should be textF1.length

    ----UPDATE-----
    It is indeed a range problem. You should find the location of textF1.text in insertString. You can refer to the implementation here: http://stackoverflow.com/ques...

    reply
    0
  • Cancelreply