如何在 iOS 上使用本机 Twitter 应用程序打开 Twitter 推文? [英] How can I open a Twitter tweet using the native Twitter app on iOS?
问题描述
可以通过 Safari 使用以下格式的链接打开推文:
http://twitter.com/1Direction_X/statuses/197752514391715842
在 iOS 5 上,Twitter 是内置的.如何使用从我的应用中调用的本机 Twitter 应用打开上述推文?
这是您从自己的应用程序访问其他应用程序的方式.只需找到发送访问状态的正确 url.我已经列出了一个列表,其中应该包含大多数重要的内容.包括状态查找.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://status?id=12345"]];
<块引用>
twitter://user?screen_name=lorenb
twitter://user?id=12345
推特://status?id=12345
推特://时间线
推特://提及
推特://消息
twitter://list?screen_name=lorenb&slug=abcd
twitter://post?message=hello%20world
twitter://post?message=hello%20world&in_reply_to_status_id=12345
twitter://search?query=%23hashtag
注意:确保用户安装了 Twitter 很重要,否则会导致崩溃.因此,我建议您在尝试将它们发送到 Twitter 之前将其添加到 if 语句中.
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]];
A tweet can be opened by Safari with a link of this format:
http://twitter.com/1Direction_X/statuses/197752514391715842
On iOS 5, Twitter is built-in. How can I open the above tweet using the native Twitter app called from my app?
This is how you access other apps from your own. Just find the proper url to send for accessing status. I've included a list that should have most of the important ones. Including status finding.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://status?id=12345"]];
twitter://user?screen_name=lorenb
twitter://user?id=12345
twitter://status?id=12345
twitter://timeline
twitter://mentions
twitter://messages
twitter://list?screen_name=lorenb&slug=abcd
twitter://post?message=hello%20world
twitter://post?message=hello%20world&in_reply_to_status_id=12345
twitter://search?query=%23hashtag
Note: It can be important to make sure the user has twitter installed or this will cause a crash. So I recommend adding this in an if statement before you try to send them to twitter.
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]];
这篇关于如何在 iOS 上使用本机 Twitter 应用程序打开 Twitter 推文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!