views:

133

answers:

2

I'm displaying a popover in ipad with a uinavigation bar. On the second view I have a UISearchController that can display a keyboard. The keyboard pushes the popover up which is fine. However if I now push the 'back' button on the UINavigation bar it dismisses the keyboard which is fine, but the popover doesn't slide back down to its original position. Anyone know how to fix that? Thanks!

A: 

Same problem...

Maxim Keegan
A: 

Ok so I actually figured out (I believe) what your question was asking...and just in case anyone stumbles upon this from google, I figured I'd answer how I did it. It feels like a hack job but I haven't been able to find any other way to do it.

In the controller that brings up the keyboard,I had it post a notification whenever the keyboard dismisses:

    [aTextField resignFirstResponder];
[[NSNotificationCenter defaultCenter] postNotificationName:@"movePopups" object:nil];

Then back on my home screen controller, that controls the UIPopover, I added a listener:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(movePopUpToRightLocation)
                                             name:@"movePopups"
                                           object:nil];    

inside the init. Be sure to remember to remove the listener in your dealloc for good programming practice:

[[NSNotificationCenter defaultCenter] removeObserver:self];

So then whenever I get notification that the keyboard disappears, I get a reference to the button that the popover shows up from, and just have it re-appear directly from it:

-(void)movePopUpToRightLocation {
NSLog(@"move pop up to right location");
if (morePopUp) {
    UIBarButtonItem *barButtonItem = (UIBarButtonItem *)[[bottomToolBar items] objectAtIndex:0];
    [morePopUp presentPopoverFromBarButtonItem:barButtonItem
                      permittedArrowDirections:UIPopoverArrowDirectionDown
                                      animated:YES];            
}   

}

I haven't added any checks for which popup it is, but I can easily do that if I have more than 1 type of popover / button that it would appear from. But that's the basic premise that you can go from.

Hope it helps!

serenn