在我的應用程序中,當用戶點擊shareToFacebook
按鈕時,我需要我的應用程序從另一個已獲得分數的ViewController截取屏幕截圖,並將其分享到Facebook。所以我寫了這樣的代碼:(它工作得很好):如何通過截圖分享Facebook和Twitter(社交框架)?
@IBAction func sharetoFacebook() {
var sharetoFacebook : SLComposeViewController =
SLComposeViewController(forServiceType:
SLServiceTypeFacebook)
sharetoFacebook.setInitialText("WOW! I scored \(rightCounter) right..! Wanna challenge me?")
shareToFacebook.addImage(UIImage(named: "//What should I put here ?"))
self.presentViewController(sharetoFacebook, animated:
true, completion: nil) }
現在,我的疑問是:爲了採取截圖從另一個視圖控制器已經拿到了分數,什麼代碼我應該投入這個:
shareToFacebook.addImage(UIImage(named: "//What should I put here ?"))
順便說一句,在此先感謝!這將是一個很大的幫助!
我不會把這個作爲一個答案,因爲我不是在我的機器並不能測試,但我想你想要做的就是使用'imageWithData'而不是你正在調用的默認創建者。從其他VC獲取數據並將其放入此處。這有點像使用Stream,如果你在.Net下熟悉它們的話。 –