xcode SLServiceTypeFacebook' 在 iOS 11.0 中被弃用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47053446/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:24:01  来源:igfitidea点击:

SLServiceTypeFacebook' was deprecated in iOS 11.0

iosswiftxcodeios11swift4

提问by danu

I'm working on a project in xcode 9 and one of my previous codes giving a warning saying the code is been deprecated, where it does not trigger the action. The code as bellow. How can i overcome this ?

我正在 xcode 9 中处理一个项目,我之前的一个代码发出警告说代码已被弃用,它不会触发操作。代码如下。我怎样才能克服这个?

@IBAction func shareOnFacebookButtonPressed(_ sender: Any) {

    let shareToFacebook : SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    shareToFacebook.add(UIImage(named:"pureLightSocial"))
    self.present(shareToFacebook, animated: true, completion: nil)
}

回答by Harshal Valanda

The Facebook, Twitter, and Other apps options have been removed in the Settingsapp.

FacebookTwitter和其他应用程序选项已经在删除Settings应用程序。

That apps will now be treated like other apps, using the iOS sharing extensions

该应用程序现在将被视为其他应用程序,使用 iOS sharing extensions

let share = [image, text, url]
let activityViewController = UIActivityViewController(activityItems: share, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)

You can also use third party SDKfor individual sharing

您也可以使用第三方SDK进行个人共享

Facebook Sharing Doc

脸书分享文件

Twitter Sharing Doc

推特分享文档