我不知道如果我理解正確,但如果你想分享的同時與Facebook的SDK文字和圖片,你可以試試這個:
NSURL *imageURL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/en/d/d3/Nasa_mer_marvin.jpg"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; // taking image from Wikipedia for example purposes
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image; // your photo
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
if ([[FBSDKAccessToken currentAccessToken].permissions containsObject:@"publish_actions"]) {
FBSDKShareAPI * shareApi = [[FBSDKShareAPI alloc]init];
shareApi.message = @"Lorem Ipsum Dolor Sit Amet"; // your text
shareApi.shareContent = content;
[shareApi share];
}
如果您試圖預先填寫文本,那麼它將不起作用,因爲它違反了政策,可能是它被刪除的原因。檢查此:http://stackoverflow.com/questions/29881531/ios-8-3-and-later-facebook-share-text-not-inserted – Bangdel
@邦戴爾同樣的事情在Android上工作。在Android中,他們首先在facebook上顯示照片,然後在用剪貼板複製的共享評論框中粘貼文本。同樣的事情,我想實現。 – Ramesh