【问题标题】:Social framework is deprecated in iOS11iOS11 已弃用社交框架
【发布时间】:2018-09-25 06:10:50
【问题描述】:

我正在制作一个示例 facebook 共享应用程序,以使用共享按钮共享一些字符串值,但我很困惑,因为社交在 ios 11 中被取消了

我现在应该使用什么代码,我已经安装了 facebook sdk for swift

我想要我已经在谷歌上搜索过的 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

标签: swift ios11 social-framework


【解决方案1】:

使用UIActivityViewController 分享内容……

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-03
    • 2012-04-20
    相关资源
    最近更新 更多