Swift - SLComposeViewController自动解除自身

时间:2017-11-13 11:14:16

标签: ios swift slcomposeviewcontroller

我正在使用SLComposeViewController进行社交照片分享。但我在日志中收到此错误

  

SLComposeViewController自动解除自身

我的代码: -

@IBAction func fbshare(_ sender:UIButton) {
    let vc = SLComposeViewController(forServiceType:SLServiceTypeFacebook)
    vc?.add(img.image!)
    vc?.add(URL(string: "http://www.example.com/"))
    vc?.setInitialText("Initial text here.")
    self.present(vc!, animated: true, completion: nil)
}

我无法在屏幕上显示SLComposeViewController

1 个答案:

答案 0 :(得分:2)

这也适用于SLServiceTypeFacebook,但是需要关闭一个来呈现另一个。我还在努力。

if let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter) {

        //SLServiceTypeFacebook
        //SLServiceTypeTwitter

        vc.setInitialText(self.writeDBString)
        //vc.add(UIImage(named: "myImage.jpg")!)
        vc.add(URL(string: "https://itunes.apple.com/us/app"))
        present(vc, animated: true )            
}