开发者

How to make a string clickable using Twui?

I have a project base on twitter's twui framework.I'm trying to made a string clickable just like

[s addAttribute:NSLinkAttributeName value:@"http://apple.com/" range:attrRange];

i开发者_开发知识库n NSMutableAttributedString, or performing a selector when clicked.

TUITextRender can draw a NSAttributedString, but "NSLinkAttributeName" doesn't work.

I can't find any method or delegate to solve this in TUITextView too.

How can I done this with twui?


After read source code, I figured it out.

  1. Store ranges in a array of ABActiveRange (Which contains in twui) subclass.
  2. Implement TUITextRendererDelegate in your UIViewController.
  3. In the activeRangesForTextRenderer: delegate method, return the array you made in step 1.
  4. Enjoy ~
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜