简体   繁体   English

iOS社交框架的Facebook问题

[英]iOS social framework for facebook issue

I recently was using social framework for posting on facebook and twitter both. 我最近使用社交框架在Facebook和Twitter上发布。 Twitter works fine, even facebook works if the device dont have facebook app in it. 如果设备没有Facebook应用,则Twitter可以正常工作,甚至Facebook也可以。 But, if it in installed then it open some other window with no initial text. 但是,如果已安装,则会打开其他没有初始文本的窗口。 Do anyone have any idea why is this happening and can this be fixed? 有谁知道为什么会这样并且可以解决吗?

在此处输入图片说明

you can share text, image, links by using SLComposeViewController, i hope it will work for u. 您可以使用SLComposeViewController共享文本,图像,链接,我希望它对您有用。

   let mySLComposerSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    mySLComposerSheet.setInitialText("Sharetext")       
    mySLComposerSheet.addURL(NSURL(string: "www.shareurl.com"))
    mySLComposerSheet.addImage(UIImage(named:"image"))
    mySLComposerSheet.completionHandler = {
    (result:SLComposeViewControllerResult) in
        mySLComposerSheet.dismissViewControllerAnimated(true, completion: { () -> Void in
            if result == SLComposeViewControllerResult.Done {
               print("success")
            } else {
                print("fail")
            }
        });
    }   
  self.presentViewController(mySLComposerSheet, animated: true) { () -> Void in

 }

swift3.0 迅捷3.0

let mySLComposerSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    mySLComposerSheet.setInitialText("Sharetext")
    mySLComposerSheet.add(URL(string: "www.shareurl.com"))

    mySLComposerSheet.add(UIImage(named: "image"))
    mySLComposerSheet.completionHandler = {
        (result:SLComposeViewControllerResult) in
        mySLComposerSheet.dismiss(animated: true, completion: { () -> Void in
            if result == SLComposeViewControllerResult.done {
                print("success")
            } else {
                print("fail")
            }
        });
    }
    self.present(mySLComposerSheet, animated: true) { () -> Void in

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM