不推荐使用SLServiceTypeTwitter':iOS 11.0中首次不推荐使用

时间:2019-01-03 00:54:50

标签: swift

在尝试使用XCode 10.1SLServiceTypeTwitter或任何其他社交媒体时,我正在使用SLServiceTypeFacebook,但我收到一个错误消息,说它们是depricated since iOS 11.0

我下载了一个运行旧版本的旧模拟器,以查看是否可以解决该问题,但是每次运行代码时,它都会使用最新的iOS版本(即没有Twitter登录选项)启动该模拟器。 / p>

@IBAction func cameraTapped(_ sender: UIBarButtonItem) {
    imagePicker.sourceType = .savedPhotosAlbum
    imagePicker.allowsEditing = false

    present(imagePicker, animated: true, completion: nil)
}

@IBAction func shareTapped(_ sender: UIButton) {
    if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeTwitter) {
        let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
        vc?.setInitialText("My food is \(navigationItem.title!)")
        vc?.add(#imageLiteral(resourceName: "hotdogBackground"))
        present(vc!, animated: true, completion: nil)

    } else {
        self.navigationItem.title = "Please log in to Twitter"
    }
}

1 个答案:

答案 0 :(得分:-4)

我找到了解决方案。我在Xcode偏好设置中加载了较旧的ios版本。完成此操作后,当我选择模拟器Xcode Show Me选项以在安装了特定ios的设备上运行我的应用程序时,便在模拟器中选择了iOS(硬件-设备)。

这解决了我的问题。

ps:如果没有(模拟器),请确保您要编译到正确的目标,如果没有,则可以随时添加模拟器。