Changing window's rootViewController does not dismiss UIActivityViewController's Mail composer's keyboard
| Originator: | RichWChan | ||
| Number: | rdar://16144455 | Date Originated: | 23-Feb-2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.0.3 |
| Classification: | UI | Reproducible: | Always |
Summary:
When setting a new rootViewController on a window, as the docs suggest, "If the window has an existing view hierarchy, the old views are removed before the new ones are installed".
In the case where there is a Mail composer presented through a UIActivityViewController, however, it seems like the Mail composer did not destroy itself properly when a new rootViewController is set -- its keyboard will remain on screen despite the composer no longer being present.
(One workaround is that, prior to setting the new root view controller, we can programmatically dismiss the original modal chain by calling dismissViewController on the old root view controller, but this doesn't seem it it should be necessary according to the documentation).
Steps to Reproduce:
1. Present a UIActivityViewController
2. Have the user choose the Mail option
3. Tap on a field to present the keyboard
4. Programmatically set the rootViewController of the window to a new view controller
Expected Results:
Everything from prior to setting the new root view controller should be removed.
Actual Results:
The Mail composer is no longer present, but its keyboard remains up.
Sample screen recordings:
screen recording demonstrating the bug:
https://www.dropbox.com/s/6xxglqcc73kgxpd/bug.mov
expected result (using the workaround mentioned in the bug report):
https://www.dropbox.com/s/9m8tg9w1qf5adiu/with-workaround.mov
Attached sample code:
```
// start with a simple root
self.window.rootViewController = [UIViewController new];
// series of ops executed sequentially in 2 sec increments:
NSArray *ops = @[
^{
// present the UIActivityViewController
NSString *shareString = @"some random string";
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ shareString ] applicationActivities:nil];
activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.window.rootViewController presentViewController:activityViewController animated:YES completion:nil];
},
^{
// TESTER SHOULD CLICK ON ONE OF THE FIELDS SO THE KEYOBARD SHOW UP NOW!
},
^{
// TESTER SHOULD CLICK ON ONE OF THE FIELDS SO THE KEYOBARD SHOW UP NOW! (give a couple extra seconds..)
},
^{
// ** NOTE ** If you don't have the following line, the keyboard from the Mail composer will not be dimissed.
// [self.window.rootViewController dismissViewControllerAnimated:NO completion:nil];
self.window.rootViewController = [UIViewController new];
self.window.rootViewController.view.backgroundColor = [UIColor redColor];
},
];
// run the blocks
[ops enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
void(^blk)() = obj;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 + 2.0 * idx * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
blk();
});
}];
```
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!