【问题标题】:Sharing to social media that install on phone iOS Swift分享到安装在手机 iOS Swift 上的社交媒体
【发布时间】:2017-05-05 03:37:33
【问题描述】:

是否有任何特定方法可以检测 iOS 手机上的所有社交媒体应用程序的共享按钮?

示例:我的手机安装了 whatsapp 和 twitter。所以当我按下分享按钮时,只有 whatsapp 和 twitter 出来了,没有 facebook 和我手机上没有安装的任何其他应用程序。

在 android 中,有使用这种方法的特殊意图。但是在 iOS 中我仍然找不到它。

注意:我需要它以编程方式用于 Swift 3

任何帮助都非常有用,谢谢

【问题讨论】:

  • 你看过UIActivityViewController吗?
  • 让我搜索一下谢谢@rmaddy
  • 感谢大佬提供的信息,现在已经完成了@rmaddy
  • 查看我在此 stackoverflow 链接上提供的答案:How to implement “share button” in Swift

标签: ios swift swift3


【解决方案1】:

你应该试试这个:

@IBAction func shareImageButton(_ sender: UIButton) 
{

    // image to share
    let image = UIImage(named: "Image")

    // set up activity view controller
    let imageToShare = [ image! ]
    let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash

    // exclude some activity types from the list (optional)
    activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook ]

    // present the view controller
    self.present(activityViewController, animated: true, completion: nil)
}

【讨论】:

  • 我已经完成了我的研究并且它有效。无论如何谢谢。干杯!
猜你喜欢
  • 2015-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-22
  • 2012-08-19
相关资源
最近更新 更多