我可以使用UIActivityViewController在Facebook上分享?(Can I u

2019-07-20 21:04发布

我试图用UIActivityViewController在Facebook上分享。 当我使用

UIImage* image = [UIImage imageNamed:@"image1.png"];
NSArray* dataToShare = @[@"test",image];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
                                  applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];

我无法看到“在Facebook上分享”图标,虽然我不排除“UIActivityTypePostToFacebook”。 是不是有对于Facebook预定UIActivity?

谢谢

Answer 1:

试试这个:如果你只想Facebook的图标分享到:

-(IBAction)shareButtonPressed:(id)sender { NSLog(@"shareButton pressed");

NSString *texttoshare = _txt;
UIImage *imagetoshare = _img;
NSArray *activityItems = @[texttoshare, imagetoshare];    
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
}

//排除的活动类型的列表中插入任何其他种类的activitytypes的要排除



Answer 2:

你必须登录到你的iPhone设置:设置 - > Facebook的



文章来源: Can I use UIActivityViewController to share on Facebook ?