在使用UISearchDisplayController + searchBar时遇到了一个问题,在IOS7系统下,当搜索时,出现tableiview的ContentSize出现错误。
具体的解决方法如下:
- (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?