uiactivityviewcontroller
How do I set recipients for UIActivityViewController in iOS 6?
For adding subject to the email using UIActivityViewController on iOS6, this is the best solution that anyone can use.. All you have to do is call the following while initializing UIActivityViewController. UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities]; [activityViewController setValue:@”My Subject Text” forKey:@”subject”]; And your UIActivityViewController is populated with a subject.
UIActivityViewController completion handler returns success when tweet has failed
Use completion handler like this For SWIFT 3 AND 4, iOS 10 AND 11 : activityVC.completionWithItemsHandler = {(activityType: UIActivityType?, completed: Bool, returnedItems: [Any]?, error: Error?) in if !completed { // User canceled return } // User completed activity } self.present(activityVC, animated: true, completion: nil)
Set different activity items for UIActivityViewController Swift
You should take advantage of the UIActivityItemSource protocol. The activityItems parameter of the initializer of UIActivityViewController accepts either an array of data objects or an array of objects that implement the UIActivityItemSource protocol. As an example consider an item source like the following. class MyStringItemSource: NSObject, UIActivityItemSource { @objc func activityViewControllerPlaceholderItem(activityViewController: UIActivityViewController) -> AnyObject { … Read more
iOS 8.3: UIActivityViewController shows extraneous row
In iOS 8, UIActivityViewController is still an API that only provides custom functions, but not custom UI. You can’t change the way it looks. The only part of the visual style you can change is the icon of your custom UIActivity subclasses. (ref) This is how Apple implements this, and it cannot be changed as … Read more
iOS: Warning “attempt to present ViewController whose view is not in the window hierarchy”
You are trying to present a view controller from the rootViewController. In your case I think the rootViewController is not the current ViewController. Either you presented or pushed a new UIViewController on top of it. You should present a view controller from the top most view controller itself. You need to change: UIViewController *vc = … Read more
How to send a PDF file using UIActivityViewController
try this NSData *pdfData = [NSData dataWithContentsOfFile:pdfFilePath]; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@”Test”, pdfData] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:nil]; and also NSString *str = [[NSBundle mainBundle] pathForResource:@”AppDistributionGuide” ofType:@”pdf”]; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@”Test”, [NSURL fileURLWithPath:str]] applicationActivities:nil];
Showing ‘UIActivityViewController’ in SwiftUI
The basic implementation of UIActivityViewController in SwiftUI is import UIKit import SwiftUI struct ActivityViewController: UIViewControllerRepresentable { var activityItems: [Any] var applicationActivities: [UIActivity]? = nil func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityViewController>) -> UIActivityViewController { let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities) return controller } func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext<ActivityViewController>) {} } And here is how to use it. … Read more
UIActivityViewController for Facebook not Showing Default Text
It would seem Facebook no longer wants developers to pre-fill posts with text. From https://developers.facebook.com/docs/sharing/ios#ios-integration: Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet’s initialText field … Read more