如何在 iOS 上使表达式可点击?
我正在写一个 Twitter 类型的客户端。我想要像@和#这样可点击的东西。当我点击它时,我希望它执行某种 IBAction。我在 OSX 上找到了这个:
http://flyosity.com/mac-os-x/clickable-tweet-links-hashtags-usernames-in-a-custom-nstextview.php
这是沿着我想要完成的事情的线条。 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-hashtags-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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我发现的最好的直接解决方案是这样的: https://github.com/SebastienThiebaud/STTweetLabel
干净简单。
The best dropin solution I've found was this: https://github.com/SebastienThiebaud/STTweetLabel
Clean and simple.
您可以使用以下代码(例如
viewDidLoad
),使任何格式正确的 URL 在UITextView
中显示为带有蓝色下划线的活动链接(例如viewDidLoad
)Search Xcode 文档和 API 参考中的“技术问答 QA1495”。
You can make any properly
formatted URLs
appear as blue underlined active links in aUITextView
with the following code (in sayviewDidLoad
)Search for "Technical Q&A QA1495" in Xcode's Documentation and API Reference.
就在我的脑海中,我想你可以通过使用 UIWebView 来显示内容来实现它(你已经链接了,按照博客文章的“2:寻找有趣的部分”部分)。
如果您随后使用自定义 URL 方案(例如
myappopenshashtags://
)为主题标签链接添加前缀,并为您的应用程序注册该 URL 方案,则您应该能够以您喜欢的任何方式打开主题标签。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.看看这个页面 http://furbo.org/2008/ 10/07/fancy-uilabels/
Look at this page http://furbo.org/2008/10/07/fancy-uilabels/