首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在iOS的特定页面上打开facebook和twitter

如何在iOS的特定页面上打开facebook和twitter
EN

Stack Overflow用户
提问于 2013-04-27 09:18:29
回答 2查看 1.3K关注 0票数 0

打开facebook和twitter显示给定页面的代码行是什么?

在Facebook上尝试过

NSURL *target = [[NSURL alloc] initWithString:@"fb://profile/WindyCityCrossFit"]; [[UIApplication sharedApplication] openURL:target];

但它只会把我带到我的新闻订阅页面。Twitter也没有给我任何结果。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-27 11:06:09

Facebook:

NSURL *url = [NSURL URLWithString:@"fb://profile/130936560286785"]; [[UIApplication sharedApplication] openURL:url];

推特:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://user?screen_name=MyTwitterID"]];

票数 2
EN

Stack Overflow用户

发布于 2013-04-27 09:59:34

这应该会让你访问facebook,尽管我不确定twitter是否会这样。

代码语言:javascript
运行
复制
NSString *urlString = <your url>;
NSString *title = <your message>;
NSString *shareUrlString = [NSString stringWithFormat:@"http://www.facebook.com/sharer.php?u=%@&t=%@", urlString , title];
shareUrlString = [shareUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            NSURL *url = [[NSURL alloc] initWithString:shareUrlString];
            [[UIApplication sharedApplication] openURL:url];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16247328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档