Share multiple photos on the same post in Facebook

2019-06-03 07:56发布

Below given code, I'm sharing 1 text and 2 photos using UIActivityViewController. Then I choose Facebook for my sharing destination and it's shared on 2 separated posts on the feed for each photo but what I want is to share it in one single post with 1 text and 2 photos. How can I achieve this? I have done lot of search on here and found no proper answer. It seems to me that Facebook may have no clear way to do this, so it's like such an issue may lie on their side.

activityItems = @[self.textDetail.text, self.imageFileView1.image, self.imageFileView2.image];

UIActivityViewController *activityController =
[[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

2条回答
来,给爷笑一个
2楼-- · 2019-06-03 08:05

Try this:

NSString *message = @"msg To post";   
NSMutableArray *postsImages=[[NSMutableArray alloc] init];
[postsImages addObject:message];
for (UIImage *img in collectionImageArray) {
    [postsImages addObject:img];
}

UIActivityViewController *activityVC = [[UIActivityViewController alloc]
                                        initWithActivityItems:postsImages
                                        applicationActivities:nil];

[activityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed,  NSArray *returnedItems, NSError *activityError) {

    if([activityType isEqualToString:UIActivityTypePostToTwitter]){
        //twitter selected
    }
}];

[self presentViewController:activityVC animated:YES completion:nil];
查看更多
时光不老,我们不散
3楼-- · 2019-06-03 08:25

The issue was solved by either new iOS ver or Facebook's new way of handling activity items. Anyway it works as I expect now.

查看更多
登录 后发表回答