-1

I am using SLComposeViewController for social sharing of photos.But i am getting this error in log

SLComposeViewController automatically dismissing itself

My code:-

@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)
}

I am not able to get the SLComposeViewController on my screen.

Yash R
  • 247
  • 2
  • 19

1 Answers1

2

This is working and for SLServiceTypeFacebook too but need to dismiss one to present the other. I am still working that out.

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 )            
}
Jigar Tarsariya
  • 3,189
  • 3
  • 14
  • 38