2015-11-03 74 views
0

降解我已经使用以下代码来捕捉的屏幕截图使用图像之前发布给Facebook:图像质量与FBSDKshareDialog和FBSDKsharephoto

UIGraphicsBeginImageContextWithOptions(CGSizeMake(frame.size.width,frame.size.height), false, 0) 
self.view?.drawViewHierarchyInRect(CGRectMake(-frame.origin.x, -frame.origin.y, view.bounds.size.width, view.bounds.size.height), afterScreenUpdates: false) 
let screenShot = UIGraphicsGetImageFromCurrentImageContext() 
UIGraphicsEndImageContext() 
return screenShot 

在我用Social FrameworkSLComposeViewController添加具有截图的第一个实例addImage。对话框和最终帖子中的图像是完美的,但这种方法不允许你选择你的朋友。

我再作如下决定使用使用FBSDKDialog

let photo : FBSDKSharePhoto = FBSDKSharePhoto() 
photo.image = screenShot 
photo.userGenerated = false 
photo.caption = contentDescription 

let photoContent : FBSDKSharePhotoContent = FBSDKSharePhotoContent() 
photoContent.photos = [photo] 
photoContent.contentURL = NSURL(string: self.contentURL) 

let shareDialog = FBSDKShareDialog() 
shareDialog.fromViewController = self 
shareDialog.shareContent = photoContent 
shareDialog.delegate = self 

if !shareDialog.canShow() { 
    shareDialog.mode = FBSDKShareDialogMode.Native 
} else { 
    shareDialog.mode = FBSDKShareDialogMode.FeedBrowser 
} 
shareDialog.show() 

代码工作完美,但在共享对话框中的图像质量极差。然而,当我做这个职位时,时间线上的图像质量是完美的。

我试图压缩图像,但似乎没有任何区别。 任何人都可以建议我做错了什么? 谢谢。

回答

0

你没有做错任何事情。这可能是Facebook优化分享的一种方式。