UISearchBar and UINavigationController
I have an .xib file connected to a ViewController, which is init'ed as the root controller of an insta开发者_JAVA技巧nce of UINavigationController in my appDelegate.
In that view, I have a UISearchBar and a UITableView below it.
When the view loads up, there's a navigationBar at the top, followed by a ~20 pixel gap, and then the UISearchBar, and the table beneath it:
My problem is that when I enter the UISearchBar to type something, the navigation bar disappears (which is fine), but the search box is all screwy:
I'm pretty new to this (a couple of weeks), so I'm not quite sure what's going on. Can anyone help me shed some light on this?
Did you pull the search bar into the parent view or into the table view? The search bar should be the header view for the table, and not as a standalone view. If you want it to be standalone anyway, make sure your autoresizing flags are correct (under cmd-3 (size) in the inspector in Interface Builder); the search bar should stick to the top and not be flexible in height.
精彩评论