gpi*_*ler 3 uitableview uisearchbar uisearchdisplaycontroller ios
我面临一个非常奇怪的问题,我无法UISearchResultsTableView
在tableView的框架内滚动到底部,而且contentSize是正确的.
只有在我点击"取消"并输入新的搜索字符串时才会发生这种情况.如果我清除此字符串并再次输入,一切正常.如果我再次单击"取消"并输入新字符串,则无法滚动到底部.在我看来,第二次搜索工作,但我遇到第一次搜索或点击"取消"按钮后出现问题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];
}
Run Code Online (Sandbox Code Playgroud)
我也把我的分类 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];
}
}
Run Code Online (Sandbox Code Playgroud)
另外我也使用自定义单元格,这样注册
[self.searchDisplayController.searchResultsTableView
registerNib:[UINib nibWithNibName:@"..." bundle:nil] forCellReuseIdentifier:@"..."];
Run Code Online (Sandbox Code Playgroud)
我解决了这个问题,我认为你需要在tableview"cellForRowAtIndexPath"方法中查看tableview contentInset属性.这不是UIEdgeInsetsZero.我通过在"cellForRowAtIndexPath"方法中设置tableview内容插入UIEdgeInsetsZero来解决它.它有点连线,但它的工作原理.
归档时间: |
|
查看次数: |
669 次 |
最近记录: |