【发布时间】:2014-11-28 12:57:58
【问题描述】:
我最近开始重写我的 iOS 应用程序以使用新的 UISearchController 和通用故事板。
我的应用程序可用于两种设备(iPhone 和 iPad),因此使用 UISplitViewController 更改通用情节提要是一大优势。
但遗憾的是,UISearchController 没有按预期工作。我用以下几行添加了UISearchController:
self.searchController = UISearchController(searchResultsController: nil)
self.searchController.searchBar.sizeToFit()
self.searchController.dimsBackgroundDuringPresentation = false
self.myTableView.tableHeaderView = self.searchController.searchBar
self.searchController.searchResultsUpdater = self
self.definesPresentationContext = true
我的控制器链是这样的:
UISplitViewController
UITabbarController (Master)
UINavigationController
UITableViewController
UINavigationController (Detail)
UINavigationController
UIViewController
问题在于,在 iPad 应用程序中,UISearchBar 被 UINavigationBar 覆盖。但是,如果我切换选项卡并返回视图。 UISearchBar 可见。因此,在切换选项卡栏后,它会以某种方式正确重绘视图。在 iPhone 版本中,它会自动正确运行。
iPad 应用程序
第一次启动后,UISearchBar 被UINavigationBar 覆盖
切换标签后UISearchBar正确显示
iPhone 应用
iPhone 应用程序在不更改选项卡的情况下正常工作..
我尝试了什么:
- 使用扩展边缘的不同设置
- 在 viewWillAppear 方法中添加 SearchController,因为我想我可以通过稍后添加搜索控件来欺骗它
【问题讨论】:
标签: ios swift ios8 uisplitviewcontroller uisearchcontroller