社交框架在iOS11中已被弃用 [英] Social framework is deprecated in iOS11

查看:0
本文介绍了社交框架在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共享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)
}

这篇关于社交框架在iOS11中已被弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆