當我只共享一個鏈接,鏈接出現。當我只共享一個圖像時,圖像出現。但是,當我想用下面的代碼執行這兩個操作時,只有鏈接出現,沒有圖像。Facebook共享問題的鏈接和屏幕截圖
我可以同時做嗎?
let screen = UIScreen.mainScreen()
if let window = UIApplication.sharedApplication().keyWindow {
UIGraphicsBeginImageContextWithOptions(screen.bounds.size, false, 0);
window.drawViewHierarchyInRect(window.bounds, afterScreenUpdates: false)
let image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
let composeSheet = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
let urlPath: String = "https://itunes.apple.com/us/app/reflex-test!-how-far-can-you/id1123340346?ls=1&mt=8"
let url: NSURL = NSURL(string: urlPath)!
composeSheet.addURL(url)
composeSheet.addImage(image)
presentViewController(composeSheet, animated: true, completion: nil)
}
}
}
我想這是爲我工作相同的代碼。同時我能夠分享鏈接和圖像。 –
@AshishVerma很奇怪...... – james
查看我的回答 –