[英]UIButton to open Facebook app
im trying to make a button that will exit my app and open up the facebook app (if available) to my apps profile. 我试图创建一个按钮,该按钮将退出我的应用程序,并向我的应用程序配置文件打开facebook应用程序(如果可用)。 And I cant figure out how I would do this.
而且我不知道该怎么做。
Get your button to call the following method when clicked: 单击按钮获取调用以下方法的按钮:
- (void)buttonClicked:(id)sender {
NSURL *url = [NSURL URLWithString:@"fb://profile/<your_profile_id>"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}
If the Facebook app is installed on your device, then it should open to your profile. 如果您的设备上安装了Facebook应用,则应打开您的个人资料。
Facebook app on the iPhone conforms to the fb:// URL pattern, fb://profile/{profile id number} will open the Facebook app to the specified profile id number iPhone上的Facebook应用符合fb://网址格式,fb:// profile / {profile id number}将打开Facebook应用至指定的个人资料ID号
You could make your button open the URL specific to your apps profile. 您可以使按钮打开特定于您的应用配置文件的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.