尝试将UISearchBar实现到UINavigationBar中,我的结果tableview位置变得错误(图2):
我花了几天时间来解决这个问题,但没有成功)
谢谢!
EDITED
在我的viewDidLoad中:
[self.searchDisplayController.searchBar setPlaceholder:NSLocalizedString(@"SEARCH_PLACEHOLDER", nil)];
[self.searchDisplayController setDisplaysSearchBarInNavigationBar:YES];
我的SearchDisplayController委托方法:
-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
//filter work repfectly
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterContentForSearchText:searchString
scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
return YES;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"not (isFav == 100)"];
[_fetchedResultsController.fetchRequest setPredicate:resultPredicate];
[self performFetch];
}