2014-07-17 4 views
3

정말 이상한 문제가 있습니다. 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:@"..."]; 
+0

검색하기 전에 tableview를 스크롤 할 수 있습니까? – Anton

+0

예, 취소 버튼 (작은 x)을 클릭하고 검색을 다시 입력 한 후에도 마찬가지입니다. 그러나 취소를 누르고 다시 입력하면 맨 아래로 스크롤 할 수 없지만 contentSize는 정확하고 tableView의 프레임입니다. – gpichler

+0

tableView에 대한 contentInsets로 재생 해 봅니다. 아마 자동 레이아웃을 비활성화합니다 – Anton

답변

5

처럼 등록 된 사용자 정의 셀을 사용하고 서브 클래스 한, 생각 당신은 tableview "cellForRowAtIndexPath"메서드에서 tableview contentInset 속성을 확인해야합니다. UIEdgeInsetsZero가 아닙니다. 나는 "cellForRowAtIndexPath"메소드의 UIEdgeInsetsZero에 설정된 tableview 내용을 Inset으로 해결했다. 조금 유선이지만 작동합니다.

+0

공유기 주셔서 감사합니다. 분명히 Apple 버그입니다. 시뮬레이터에서 인세 트가 변경되지 않습니다 ... 레이더를 제기했습니다. 18629948 – hyouuu

+0

어떻게/왜 이것이 'UITableView'의 스크롤을 가능하게합니까? – MortalMan