swift - iOS11 已弃用社交框架
问题描述
我正在制作一个示例 facebook 分享应用程序来使用分享按钮分享一些字符串值,但我很困惑,因为社交在 ios 11 中被破坏了
我现在应该使用什么代码,我已经为 swift 安装了 facebook sdk
我想要我已经在谷歌上搜索过的 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
分享内容……</p>
@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)
}
推荐阅读
- linq - SingleOrDefault in F#
- dialogflow-es - 有没有办法将一个意图的内容复制到另一个意图?
- python - 如何在另一个表的特定属性上设置 ForeignKey?
- java - 如何使 JFileChooser 中的“查找”字段在 Windows 上可编辑?
- xml - 如何使用 xmlstarlet 将元素插入 xml?
- protractor - 如何使用 Protractor 正确通过 reCaptcha 系统
- android - NFC Tag 轻触时创建的新程序实例
- haskell - Haskell - 检查一阶逻辑公式是否关闭/句子
- karate - 在 karate-netty 中定义一个常数
- python-3.x - Forming a Dictionary from results