开发者

How to make an expression clickable on iOS?

I am writing a Twitter type client. I want stuff like @ and # clickable. When I click on it, I want it to do some sort of IBAction. I found this for OSX:

http://flyosity.com/mac-os-x/clickable-tweet-links-hashta开发者_StackOverflow中文版gs-usernames-in-a-custom-nstextview.php

This is along the lines of what I want to accomplish. Anything for iOS that is of this caliber?


The best dropin solution I've found was this: https://github.com/SebastienThiebaud/STTweetLabel Clean and simple.


You can make any properly formatted URLs appear as blue underlined active links in a UITextView with the following code (in say viewDidLoad)

self.myTextView.editable = NO;
self.myTextView.dataDetectorTypes = UIDataDetectorTypeLink;

Search for "Technical Q&A QA1495" in Xcode's Documentation and API Reference.


Just off the top of my head, I guess you could achieve it by using a UIWebView to display the content (which you have linkified, as per the "2: Finding The Interesting Parts" part of the blog post).

If you then prefix the hashtag links with a custom url scheme, like myappopenshashtags://, and register that url scheme for your app, you should be able to open your hashtags in whatever way you please.


Look at this page http://furbo.org/2008/10/07/fancy-uilabels/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜