activityViewController

activityViewController

我想共享一个URL,就像Safari在我自己的iOS应用中所做的一样,我该怎么做?
使用社交框架可以在某些特定的社交平台上共享,但就我而言,我只想共享Safari这样的网址。

最佳答案

您是否认为UIActivityViewController?

ios - 我如何在自己的应用程序中共享Safari这样的网址-LMLPHP

@IBAction func shareTextButton(_ sender: UIButton) {

    // image to share
    let link = "https://www.google.rs/"

    // set up activity view controller
    let activityViewController = UIActivityViewController(activityItems: [link], 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)


}

08-27 17:41