从 Facebook 4.0 更新开始,您可以跳转到具有以下 URI 架构的页面:
fb://page/{fbid}
Run Code Online (Sandbox Code Playgroud)
只需确保您检查以确保您正在使用的设备可以响应它:
[[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"fb://page/{fbid}"]];
Run Code Online (Sandbox Code Playgroud)
你的方法最终可能看起来像这样:
- (IBAction)openFBPage:(id)sender {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"fb://page/{fbid}"]]) {
[[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"fb://page/{fbid}"]];
} else {
NSLog(@"Facebook isn't installed.");
// or do the sensible thing and openURL the HTTP version of the page in safari
}
Run Code Online (Sandbox Code Playgroud)
...并且您可以将上述方法与 Interface Builder 中的按钮链接起来。
| 归档时间: |
|
| 查看次数: |
805 次 |
| 最近记录: |