Kong Hantrakool Kong Hantrakool - 1 year ago 199
iOS Question

PopViewControllerAnimated:YES when tap on UIAlertView make Keyboard appear in parentVC

I tried to programmatically popViewcontroller
By doing this

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

[[self navigationController] popViewControllerAnimated:YES];


The problem is I have textFields in this VC.If the textField is active and keyboard is displaying, and if I display the AlertView with use to command to resign keyboard (
[[self view] endEditing:YES] or [textField resignFirstResponder]
). And then call the command popViewControllerAnimated:YES . The current VC is dismissed but briefly after the parent VC is appear. There will be a keyboard shown for like 1 second and then disappear.

This behaviour is very annoying. Are there anyway to solve this ? I noticed that by using
[[self navigationController] popViewControllerAnimated:NO]
The keyboard won't appear . But I prefer to have animation in my app.

Please help.

Thanks in advance

Answer Source

I solved this problem my making the [[self navigationController] popViewControllerAnimated:YES]; delayed when called.

   dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 100 *      NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
    [[self navigationController] popViewControllerAnimated:YES];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download