SearchBar rotation problem
I am sorry for images but I don't know better way to explain my problem. This is view when I start application, all is fine.
This is the code how I create and add search bar:
- (void) loadView
{
[super loadView];
sBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0,0,320,45)];
sBar.delegate = self;
sBar.placeholder = @"Search";
self.tableView.tableHeaderView = sBar;
UISearchDisplayController *searchDC = [[UISearchDisplayController alloc] initWithSearchBar:sBar contentsController:self];
self.searchDisplayController = searchDC;
searchDC.delegate = self;
searchDC.searchResultsDataSource = self;
searchDC.searchResultsDele开发者_如何转开发gate = self;
[sBar release];
[searchDC release];
}
I didn't change anything in rotation methods specifically for navigation or search bar.
Verify all your views frames in:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
And if they are not ok set the correct frame.
The simpliest solution is to add UISearchBar
to UITableView
header. In this case all staff will be handled out of the box.
Setting frame can cause problems with UISearchBar width while switching between views and rotating. I experienced this issue in tab based app. Yeah, the test case is not so easy to reproduce, but stil it's a bug.
精彩评论