Swift Share With

[Solved] Swift Share With | Swift - Code Explorer | yomemimo.com
Question : swift share with

Answered by : crowded-caterpillar-xo733sicd6cc

import UIKit
class ViewController: UIViewController { // share text @IBAction func shareTextButton(_ sender: UIButton) { // text to share let text = "This is some text that I want to share." // set up activity view controller let textToShare = [ text ] let activityViewController = UIActivityViewController(activityItems: textToShare, 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) } // share image @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) }
}

Source : https://stackoverflow.com/questions/35931946/basic-example-for-sharing-text-or-image-with-uiactivityviewcontroller-in-swift | Last Update : Fri, 15 May 20

Answers related to swift share with

Code Explorer Popular Question For Swift