UISearchDisplayController's searchResultsTableView在IOS7下的一個bug

在使用UISearchDisplayController + searchBar時遇到了一個問題,在IOS7系統下,當搜索時,出現tableiview的ContentSize出現錯誤。iview

圖片描述

具體的解決方法以下:ide

- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView {

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];

}



- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView {

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil];

}



- (void) keyboardWillHide {

    UITableView *tableView = [[self searchDisplayController] searchResultsTableView];

    [tableView setContentInset:UIEdgeInsetsZero];

    [tableView setScrollIndicatorInsets:UIEdgeInsetsZero];

}

具體狀況附上連接地址 :UISearchDisplayController's searchResultsTableView's ContentSize is incorrect. Bug in iOS 7?ui

2015年1月16更新

使用上面的方法雖然能解決問題,但當數據太多時,顯示仍是有問題,下面的代碼,替換成下面的方法能夠解決!spa

c-(void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView
{
    [tableView setContentInset:UIEdgeInsetsZero];
    [tableView setScrollIndicatorInsets:UIEdgeInsetsZero];
}
相關文章
相關標籤/搜索