Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.05k stars 1.37k forks source link

UISearchController.searchBar 作为 UITableView.tableHeaderView 时,进入搜索状态,搜索结果列表顶部有一大片空白 #1473

Closed MoLice closed 11 months ago

MoLice commented 1 year ago

截图

image

如何重现

self.searchController = [[UISearchController alloc] initWithSearchResultsController:SearchResultController.new];
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.placeholder = @"点我搜索啊";
self.tableView.tableHeaderView = self.searchController.searchBar;

Demo:TestSearchController.zip

Lookin:QMUIDemo#1473.lookin.zip

预期的表现

搜索结果列表顶部和 searchBar 应该贴合在一起。

其他信息

MoLice commented 1 year ago

建议这里不要让系统自动调整 scrollView.contentInset,因为在搜索结果列表 push 进入下一级界面时 navigationBar 会经历隐藏→显示的切换,这个切换过程,scrollView.contentInset 也会跟着跳变,导致列表跳动。所以干脆将 contentInsetAdjustmentBehavior 设置为 Never 来避免 bug 及跳动。

MoLice commented 11 months ago

已发布 4.7.0 修复该问题。