Tencent / QMUI_iOS

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

[UIKit Bug] UISearchBar 作为 tableHeaderView 使用时,切换 tableView 的 sectionIndex 的显隐,searchBar 的布局可能无法刷新 #1213

Closed MoLice closed 3 years ago

MoLice commented 3 years ago

Bug 表现 当 UISearchBar 作为 tableHeaderView 使用时,如果 UITableView 显示了 sectionIndex,那么 searchBar 内部会自动在右边腾出空白,如下图所示:

但当 sectionIndex 隐藏后,searchBar 没有刷新,依然保留那段空白,这应当是不符合预期的。

如何重现

  1. tableView.tableHeaderView = searchBar
  2. sectionIndexTitlesForTableView return @[xxx]
  3. sectionIndexTitlesForTableView return nil

以下是可重现的 Demo:TestSearchBarInsets.zip。注意解决方案也在 Demo 里,只是被注释掉了。

预期的表现 sectionIndexTitlesForTableView 发生变化时,searchBar 的布局都应该得到刷新。

其他信息

MoLice commented 3 years ago

已发布 4.2.3 修复该问题。