UISearchDisplayController's searchResultsTableView在IOS7下的一个bug
文章目录
在使用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?
2015年1月16更新
使用上面的方法虽然能解决问题,但当数据太多时,显示还是有问题,下面的代码,替换成下面的方法可以解决!
c-(void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView { [tableView setContentInset:UIEdgeInsetsZero]; [tableView setScrollIndicatorInsets:UIEdgeInsetsZero]; }
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论