iOS:activityType不适用于UIactivityViewController

时间:2017-07-06 13:02:04

标签: ios swift uiactivityviewcontroller facebook-share

嗨,这是我的代码我实现了UIactivityViewCotroller但是当我点击时我没有看到邮件和Facebook应用程序

@IBAction func activityView(_ sender: UIButton) {
    let text = "This is some text that I want to share."
    let textToShare = [ text ]
    let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view
    activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook, UIActivityType.mail ]
    self.present(activityViewController, animated: true, completion: nil)
}

但我没有看到那些应用 我该怎么办?

1 个答案:

答案 0 :(得分:0)

替换功能如下

@IBAction func activityView(_ sender: UIButton) {
    let text = "This is some text that I want to share."
    let textToShare = [ text ]
    let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view
        activityViewController.excludedActivityTypes = [ UIActivityType.airDrop ]
    self.present(activityViewController, animated: true, completion: nil)
}

活动控制器excludedActivityTypes表示您要排除要在activityController

列出的共享选项