2015-11-03 72 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優化分享的一種方式。