社交框架在iOS11中已被弃用已被、社交、框架

由网友(暮色凉城ん一地凄凉)分享简介:我正在制作一个示例Facebook共享应用程序,以便使用共享按钮共享一些字符串值,但我感到困惑,因为iOS 11中的社交功能是分散的我已经为Swift安装了Facebook SDK,现在应该使用哪些代码我想要SIWFT语言的代码,我已经在谷歌上搜索过了,我发现没有代码,这对我的情况很有用以下是我在onclikButto...

我正在制作一个示例Facebook共享应用程序,以便使用共享按钮共享一些字符串值,但我感到困惑,因为iOS 11中的社交功能是分散的

我已经为Swift安装了Facebook SDK,现在应该使用哪些代码

iOS 11对比iOS 10 升不升级全看你

我想要SIWFT语言的代码,我已经在谷歌上搜索过了,我发现没有代码,这对我的情况很有用

以下是我在onclikButton操作下使用的代码

@IBAction func shareButton(_ sender: Any) {


let alert = UIAlertController(title: "Share", message: "Poem Of the day", preferredStyle: .actionSheet)

    let actionOne = UIAlertAction(title: "Share on Facebook", style: .default) { (action) in
        print("Success")



    }

    alert.addAction(actionOne)
    self.present(alert, animated: true, completion: nil)

}

编辑:-找到了使用以下代码在Facebook上共享帖子的更好方法

@IBAction func shareButton(_ sender: Any) {



    let content = FBSDKShareLinkContent()
    content.contentURL =  URL(string: "https://github.com/EndLess728")


    let dialog : FBSDKShareDialog = FBSDKShareDialog()
    dialog.fromViewController = self
    dialog.shareContent = content
    dialog.mode = FBSDKShareDialogMode.feedWeb
    dialog.show()

}

推荐答案

使用UIActivityViewController共享Content…

@IBAction func share(_ sender: Any) {

    let sharingItems: [Any] = [URL(string: "https://github.com/EndLess728")]

    let activityController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)

    present(activityController, animated: true)
}
阅读全文

相关推荐

最新文章