정말 이상한 문제가 있습니다. UISearchResultsTableView
의 아래쪽으로 스크롤 할 수 없으므로 tableView의 프레임과 contentSize가 정확합니다.UISearchResultsTableView의 아래쪽으로 스크롤 할 수 없습니다.
"취소"를 클릭하고 새 검색 문자열을 입력하는 경우에만 발생합니다. 이 문자열을 지우고 다시 입력하면 모든 것이 올바르게 작동합니다. '취소'를 다시 클릭하고 새 문자열을 입력하면 아래로 스크롤 할 수 없습니다. 두 번째 검색 작업이 마음에 들지만 첫 번째 검색에 문제가 있거나 UISearchBar
의 "취소"버튼을 클릭 한 후 문제가 있습니다.
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[self searchForText:searchString];
return YES;
}
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil];
}
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
tableView.rowHeight = 70;
}
- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
- (void)keyboardWillHide
{
UITableView *tableView = [[self searchDisplayController] searchResultsTableView];
[tableView setContentInset:UIEdgeInsetsZero];
[tableView setScrollIndicatorInsets:UIEdgeInsetsZero];
}
나는 또한 나의이 또한 UISearchDisplayController
- (void)setActive:(BOOL)visible animated:(BOOL)animated
{
if(self.active == visible) return;
[self.searchContentsController.navigationController setNavigationBarHidden:YES animated:NO];
[super setActive:visible animated:animated];
[self.searchContentsController.navigationController setNavigationBarHidden:NO animated:NO];
if (visible) {
[self.searchBar becomeFirstResponder];
} else {
[self.searchBar resignFirstResponder];
}
}
나는 또한 내가 문제를 해결이
[self.searchDisplayController.searchResultsTableView
registerNib:[UINib nibWithNibName:@"..." bundle:nil] forCellReuseIdentifier:@"..."];
검색하기 전에 tableview를 스크롤 할 수 있습니까? – Anton
예, 취소 버튼 (작은 x)을 클릭하고 검색을 다시 입력 한 후에도 마찬가지입니다. 그러나 취소를 누르고 다시 입력하면 맨 아래로 스크롤 할 수 없지만 contentSize는 정확하고 tableView의 프레임입니다. – gpichler
tableView에 대한 contentInsets로 재생 해 봅니다. 아마 자동 레이아웃을 비활성화합니다 – Anton