首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >社交框架在iOS11中已弃用

社交框架在iOS11中已弃用
EN

Stack Overflow用户
提问于 2018-09-25 14:10:51
回答 1查看 716关注 0票数 0

我正在制作一个样例facebook分享应用程序,使用分享按钮分享一些字符串值,但我感到困惑,因为社交在ios 11中是分散的

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

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

下面是我在onclikbutton操作下使用的代码

代码语言:javascript
复制
@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上分享帖子的更好方法

代码语言:javascript
复制
@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()

}
EN

回答 1

Stack Overflow用户

发布于 2018-09-25 16:16:20

使用UIActivityViewController共享content…

代码语言:javascript
复制
@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)
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52491654

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档