6
votes

Hello I have a ABPeoplePickerNavigationController, on creation is set its navigationBar hidden.

peoplePickerController.navigationBar.hidden = YES;

This works perfectly, the only problem is that when the user taps the search box to search for a person, as he return's from the search, the navigationBar is re-displayed,. How can I get notified of this and make the navigationBar hidden again ?

I also think this is an apple bug, since on regular cases when search is tapped, the navigation bar is hidden to make for more room, and later displayed, but it does not take into account the fact that the bar could have been hidden in the first place.

Any trick's welcomed.

2

2 Answers

22
votes

The safest and simplest method is to track when the keyboard hides/shows.

- (void)keyboardWillHide:(NSNotification *)notification
{
    peoplePickerController.navigationBar.hidden = YES;
}

- (void)hideNavbarAndKeepHidden
{        
    peoplePickerController.navigationBar.hidden = YES;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];   
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}
3
votes

If you believe this is a bug you should submit it to http://bugreporter.apple.com.

To me it also sounds like a bug, but I'd double-check with the documentation to make sure. If it doesn't mention anything, then I suggest reporting the bug.

Edit: On the other hand, I would think setting the navigation bar here to be hidden is a bad idea. Is there a particular reason for wanting to hide it?