Я скрыл свою навигационную панель в моем контроллере просмотра таблицы, но после выбора строки поиска и затем отклонения ее с помощью Отмена, она снова отображает панель навигации. Я попыталсяСкрыть панель навигации после использования строки поиска
-(void)searchBarTextDidEndEditing:(UISearchBar *)searchBar {
self.navigationController.navigationBar.hidden = YES;
}
Но это не сработало, он сделал скрыть навигационную панель с точки зрения детализации, хотя, но это не желательно.
В раскадровке у меня есть tabBarController -> navigationController -> tableView -> detailview.
EDITED:
Мой код:
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterContentForSearchText:searchString
scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar
selectedScopeButtonIndex]]];
return YES;
}
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"name contains[c] %@", searchText];
searchResults = [_truckArray filteredArrayUsingPredicate:resultPredicate];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (tableView == self.searchDisplayController.searchResultsTableView) {
return 1;
} else {
return [_sectionTitles count];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.searchDisplayController.searchResultsTableView) {
if (section == 0) {
[_sectionTitles replaceObjectAtIndex:0 withObject:@""];
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
return [searchResults count];
} else {
return 0;
}
} else {
NSString *sectionName = [_sectionTitles objectAtIndex:section];
NSArray *sectionArray = [_sections objectForKey:sectionName];
return [sectionArray count];
}
}
В cellForRowAtIndexPath:
Item *item = nil;
if (tableView == self.searchDisplayController.searchResultsTableView) {
item = [searchResults objectAtIndex:indexPath.row];
} else {
NSString *sectionTitle = [_sectionTitles objectAtIndex:indexPath.section];
NSArray *sectionArray = [_sections objectForKey:sectionTitle];
item = [sectionArray objectAtIndex:indexPath.row];
}
У вас есть попытки - (void) searchBarCancelButtonClicked: (UISearchBar *) searchBar – Mukesh
Да, но панель навигации все еще существует. – pouncelciot
Ур поисковая строка переходит на панель навигации при поиске? Может у пост ур код, как и инициализировать строку поиска – Mukesh