I am using an instance of UIActivityViewController
in a universal app. It works absolutely perfectly on the iPad. Nearly, but not quite on the iPhone.
I present it using:
[self presentViewController:self.activityViewController animated:YES completion:nil];
It displays the available activities correctly and if I choose one, it works. I can then tap on the Share button again and repeat with the same or a different activity as often as I like, so long as I complete the activity.
If I Cancel from the UIActivityViewController
, all is well; but if I cancel from, say, Mail or Message, the next time I tap on Share, nothing happens. If I get impatient and tap again, I get the following error:
'Application tried to present modally an active controller .'
I've tried dismissing the controller before presenting it a second time, but it doesn't think it is dismissible. I've also tried presenting it from the root/navigation controller as well as the tableviewcontroller, but get the equivalent error (i.e. the app tried to present the root controller).
I see there are lots of 'odd' problems with UIActivityViewController
, but I can't see anything relevant to my problem.
The problem was due to the example code I'd used. I assumed that the dismiss code was being executed, when it wasn't!
I ended up implementing UIPopoverControllerDelegate and implementing:
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
[self setPopoverActivity:nil];
}
This fixed it!