Reputation: 131
I am using an UIActivityViewController. When the user sends my application to the background on the iPhone (when they press the home button, etc) I need to remove the spawned UIActivityViewController and any children that may have come from it. This is to say that if the user selects the "Mail" or "Message" option on the UIActivityViewController I need to remove the view (view controller?) that spawns as a result of this action.
I have tried the following code by found that it only removes the original UIActivityViewController and none of the additional views it spawned.
[_myActivityController dismissViewControllerAnimated:NO completion:nil];
Upvotes: 2
Views: 268
Reputation: 359
Try this in your appDelegate applicationDidEnterBackground. Dismiss the top most view controller which is presented. Hope this will help you out.
- (void)applicationDidEnterBackground:(UIApplication *)application {
UIViewController *mytopController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (mytopController.presentedViewController)
{
mytopController = mytopController.presentedViewController;
[mytopController dismissViewControllerAnimated:NO completion:nil];
}
}
Upvotes: 1