我想将图片,网址和文字分享到Facebook,我无法在iOS9上运行。这是我的代码。
-(IBAction)shareOnFacebook:(id)sender{
UIButton *btn = (UIButton *)sender;
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:SHARING_QUOTE_D(self.dish.name, self.dish.restaurant.name)];
[controller addURL:[NSURL URLWithString:SHARING_URL]];
[controller addImage:self.dishImageView.image];
[self presentViewController:controller animated:YES completion:Nil];
if ([controller respondsToSelector:@selector(popoverPresentationController)])
{
UIPopoverPresentationController *presentationController = [controller popoverPresentationController];
presentationController.sourceView = btn; // if button or change to self.view.
}
}else{
[[[UIAlertView alloc] initWithTitle:@"Error Message" message:@"Please log into your Facebook account to post" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] show];
}
}
答案 0 :(得分:0)
您必须使用新的Facebook SDK进行共享。您还需要设备中的Facebook应用程序。 iOS 9将关闭SLComposeView并可能会显示警告“....不支持...”