我有FBSDK共享功能用下面的代碼工作:使用Swift將UIImage直接添加到FBSDKShareLinkContent中?
if (FBSDKAccessToken.currentAccessToken() != nil) {
// User is already logged in, do work such as go to
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: self.url_string)
content.contentTitle = self.title_text
content.contentDescription = self.desc_text
content.imageURL = NSURL(string: "http://image.png")
let button : FBSDKShareButton = FBSDKShareButton()
button.shareContent = content
button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 30)
button.center = self.view.center
self.view.addSubview(button)
}
的問題是,我沒有一個IMAGEURL,我直接從存儲爲一個UIImage變量應用的相機功能拍攝的圖像。如何在沒有在線託管圖像的情況下將圖像附加到此FBSDKShareLinkContent?我使用的是FBSDKShareLinkContent,因爲我還分享了鏈接w /標題&說明。
編輯我試圖用FBSDKSharePhoto(正如某人所建議的)使用此代碼發佈照片,但即使content.contentURL
被定義爲之前的版本,我仍無法正確鏈接該網址。
let photo : FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = self.scaledImage
photo.userGenerated = true
let content : FBSDKSharePhotoContent = FBSDKSharePhotoContent()
content.contentURL = NSURL(string: self.url_string)
content.photos = [photo]
let button : FBSDKShareButton = FBSDKShareButton()
button.shareContent = content
button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 30)
button.center = CGPointMake(self.view.center.x, self.descLabel.center.y + 51 + 30) // 51 = 1/2 of height of descLabel, 30 = space below
self.view.addSubview(button)
對於本地照片共享,您可以使用'FBSDKSharePhotoContent'。鏈接共享實際上共享一個鏈接(在線內容),並附加到它的imageUrl屬性是它的參考圖像。我也想做你所要求的東西,但找不到任何東西... – Pushparaj
事情是我想分享一個標題和描述旁邊的圖像鏈接。我不認爲我可以這樣做FBSDKSharePhotoContent – Andrew
如果我使用FBSDKSharePhotoContent我可以讓圖像發佈,但我怎麼得到那裏的鏈接? – Andrew