gpt4 book ai didi

ios - 无法在 UISearchResultsTableView 中滚动到底部

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:56 25 4
gpt4 key购买 nike

我遇到了一个非常奇怪的问题,尽管 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:@"..."];

最佳答案

我解决了这个问题,我认为您需要检查 TableView “cellForRowAtIndexPath”方法中的 TableView contentInset 属性。这不是 UIEdgeInsetsZero。我通过在“cellForRowAtIndexPath”方法中将 tableview 内容 Inset 设置为 UIEdgeInsetsZero 来解决它。它有点连线,但可以正常工作。

关于ios - 无法在 UISearchResultsTableView 中滚动到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24797120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com