iOS7中的UISearchDisplayController结果表位置问题

时间:2014-10-03 03:14:11

标签: ios7 uinavigationbar uisearchbar

尝试将UISearchBar实现到UINavigationBar中,我的结果tableview位置变得错误(图2):

Initial view Search result view

我花了几天时间来解决这个问题,但没有成功)

谢谢!

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];
}

0 个答案:

没有答案