I've try to send an email over the UIActivityViewController and it works fine, but the mail view is not dismissed after the email was send. It also wont't dismiss when the user has pushed the Cancel button.
What can I do to fix the problem?
Here the code I have used:
//conf share view
NSString *textToShare = @"Teststring!";
UIImage *imageToShare = fetchedImage;
NSURL *urlToShare = [NSURL URLWithString:string_url];
NSArray *activityItems = [[NSArray alloc] initWithObjects:textToShare, imageToShare,urlToShare,nil];
UIActivity *activity = [[UIActivity alloc] init];
NSArray *applicationActivities = [[NSArray alloc] initWithObjects:activity, nil];
UIActivityViewController *activityVC =
[[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:applicationActivities];
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact,
UIActivityTypePostToWeibo,
UIActivityTypeCopyToPasteboard,
UIActivityTypeSaveToCameraRoll,
UIActivityTypePrint];
[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
NSLog(@"CompletionHandler was called!");
}];
Thanks!
I have the solution. You want to present the UIActivityViewController in your fundamental, i.e. your highest or last view controller. In my case, this worked:
[[[self parentViewController] parentViewController] presentViewController:activityViewController animated:YES completion:nil];
Try out yourself how many times you have to call parentViewController until you are accessing the highest view controller. In my simple MasterView/DetailView app, I had to call it twice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With