2013-03-03 60 views
5

我想用UIActivityViewController在facebook上分享。 當我使用我可以使用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?

感謝

回答

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]; 
} 

//排除的活動類型的列表中插入任何其他種類的activitytypes的要排除

+0

如何排除提醒和備註? – huyleit 2016-03-18 10:04:34

8

您必須先登錄iphone設置: 設置 - > facebook

相關問題