开发者

How to make a string clickable using Twui?

开发者 https://www.devze.com 2023-03-25 08:03 出处:网络
I have a project base on twitter\'s twui framework.I\'m tryingto made a string clickable just like [s addAttribute:NSLinkAttributeName value:@\"http://apple.com/\" range:attrRange];

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

精彩评论

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