UIButton to open Facebook app
im trying to make a button that will exit my app and open up the facebook app (if available) 开发者_JAVA技巧to my apps profile. 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 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
You could make your button open the URL specific to your apps profile.
精彩评论