我可以使用UIActivityViewController在Facebook上分享吗?

时间:2013-03-03 18:01:17

标签: facebook ios6 uiactivityviewcontroller

我正在尝试使用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];

虽然我没有排除“UIActivityTypePostToFacebook”,但我看不到“在Facebook上分享”图标。 Facebook没有预定义的UIActivity吗?

由于

2 个答案:

答案 0 :(得分:9)

您必须登录iphone设置: 设置 - >实

答案 1 :(得分:3)

试试这个:如果你只想分享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];
}

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