如何分享截图到Facebook

时间:2015-06-14 22:31:07

标签: objective-c facebook facebook-sdk-4.0 social-media

我已经完成了截图部分,但仍然没有找到任何解决方案来使用FBSDKSharePhoto将截图图像分享到Facebook。 Facebook没有为它提供足够的参考。有人可以在这里指导我吗?

以下是我的截图代码:

CGRect screenRect = [[UIScreen mainScreen] bounds];

UIGraphicsBeginImageContextWithOptions(screenRect.size, NO , 0.0f);

CGContextRef ctx = UIGraphicsGetCurrentContext();

[[UIColor blackColor] set];

CGContextFillRect(ctx, screenRect);



UIWindow *window = [UIApplication sharedApplication].keyWindow;



[window.layer renderInContext:ctx];

UIImage *screengrab = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

1 个答案:

答案 0 :(得分:0)

我相信你想要FBSDKSharePhotoContent和FBSDKShareDialog。您需要将您的内容设置为照片:

UIImage *screengrab = UIGraphicsGetImageFromCurrentImageContext();
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[[FBSDKSharePhoto photoWithImage:screengrab userGenerated:YES]];

// Assuming self implements <FBSDKSharingDelegate> 
[FBSDKShareAPI shareWithContent:content delegate:self];