gpt4 book ai didi

swift - 社交框架在 iOS11 中被弃用

转载 作者:行者123 更新时间:2023-11-28 14:11:29 27 4
gpt4 key购买 nike

我正在制作一个示例 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 分享内容……

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

关于swift - 社交框架在 iOS11 中被弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52491654/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com