2016-07-12 60 views
2

我想在我的應用程序中有一個分享按鈕,用於分享到Facebook。 我決定用社交框架來做,因爲我相信這很容易。 我錯了......社交框架無法正常工作Swift

這裏是我的代碼:

@IBAction func facebookButton(sender: AnyObject) { 
     if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) { 
      let fbSheet = SLComposeViewController(forServiceType: SLServiceTypeFacebook) 
      fbSheet.setInitialText("Some text") 
      fbSheet.addImage(UIImage(named: "loading")) 
      fbSheet.addURL(NSURL(string: "http://www.something.com")) 
      presentViewController(fbSheet, animated: true, completion: nil) 
     } else { 
      self.showAlert("Facebook", msg: "Please login to your Facebook account in Settings") 
     } 
    } 

此代碼工作,但它返回只有網址,如果我評論它;它只返回圖像。 我已經改變了順序,我把圖像放在第三位,但它只是返回唯一的網​​址。 這就像它有優先權,它只返回其中的一個。

+0

https://iosdevcenters.blogspot.com/2017/08/how-to-share-content-with.html –

回答