![]() Now we are going to go to the ContentView and add the following code. We also added updateUIViewController function to keep the Controller up to date with any changes. fileManager.createFile(atPath: paths as String, contents: pdfDoc as Data, attributes: nil). Then inside of the function we set our UIActivityViewController with the content ( itemsToShare) and the list of services ( servicesToShareItem) we want to display in the controller. let pdfDoc NSData(contentsOf:URL(string: documentPathToLoad)). let videoUrl NSURL(fileURLWithPath: local/video/url/path/) var. This is where we sent the context to UIActivityViewController so it can be displayed in SwiftUI. When using the iOS UIActivityViewController / Documentation Interaction API to share. Next we setup the makeUIViewController function. I tried the code given below to share (on Facebook/Whatsapp etc) a UIImage and a String. The variable itemsToShare is for our content that we want to pass to other services and servicesToShareItem is to get a list of service we can uses to share our content. How to share image & text/url using UIActivityViewController. Next we are setting up our variables itemsToShare and servicesToShareItem. What this struct is doing is setting itself as a UIViewControllerRepresentable so we can gain access to UIKit’s classes. UIActivityViewController SwiftAre you looking for chart for uiactivityviewcontroller tutorial Want to learn how to use share sheet ios This uiactivityviewc. struct ActivityViewController: UIViewControllerRepresentable Then we are going to add the following struct to our code outside of our ContentView. Last week, we tested again the app and saw that we can not share via Instagram from our app at device run iOS 13.6, only Instagram sharing got this problem. Here is how to implement it.įirst we need to import UIKit to get access to UIActivityViewController. Can not share URL to Instagram on iOS 13.6 with UIActivityViewController. All you need to do is tell it what kind of content you want to share and UIActivityViewController take care of most of the heavy lifting. Sponsor Hacking with Swift and reach the world's largest Swift community Available from iOS 6.0 see Hacking with Swift tutorial 3. ![]() UIActivityViewController is a class that makes sharing content to other services on your apple device super simple. To use UIActivityViewController, you just need to pass some data to it (like text, a URL, or an image), then present the view controller.
0 Comments
Leave a Reply. |