Search code examples
objective-ccocoatwui

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];

in 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?


Solution

  • 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 ~