views:

78

answers:

1

I use the following code to display a UISearchBar with a Scope Bar.

UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 45)];
searchBar.barStyle = UIBarStyleDefault;
searchBar.showsCancelButton = NO;
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;

searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"One", @"Two", nil];
searchBar.showsScopeBar = YES;

self.tableView.tableHeaderView = searchBar;

[searchBar release];

However, the scope bar is never displayed. Why is it not being displayed and how can I fix this?

+1  A: 

in the initWithFrame:CGRectMake(0, 0, 320, 45), the height is only the height of a search bar, not including a scope bar. Try replacing with something like:

UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 90)];
Felixs
Thanks very much! So simple.
Joshua