【问题标题】:UISearchController not showing on iOS8UISearchController 未在 iOS8 上显示
【发布时间】:2016-04-08 04:15:11
【问题描述】:

我有一个 UISearchController,它的 searchBar 设置为我的 tableView 的 tableHeaderView:

tableView.tableHeaderView = searchController.searchBar

在我运行 iOS9 的设备上运行良好:

但是当我在运行 iOS8 的设备上运行它时,没有搜索栏。

根据我的阅读,UISearchController 适用于 iOS8 及更高版本。所以我不明白为什么它的 searchBar 没有出现在我的 iOS8 设备上。

【问题讨论】:

  • @MuhammadAdnan 我已经设置为 true

标签: ios uisearchcontroller


【解决方案1】:

UISearchBar 不会自动设置其大小添加此代码:

[searchController.searchBar sizeToFit];

Apple Sample

【讨论】:

  • 这已经解决了这个问题。但是,搜索器最初出现在 tableView 中的第一个单元格上。编辑:我通过在将 searchBar 设置为 tableView 的 headerView 之前调用 sizeToFit 解决了这个问题。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多