【发布时间】:2016-03-24 15:44:46
【问题描述】:
在 iOS 9 中,我正在使用 UISearchController 并在 UIViewController 中显示其搜索栏,当我第一次单击搜索栏并尝试了我能想到的一切都无济于事时,我遇到了很多滞后...下面是我的代码以及延迟发生的视频的链接 - 延迟发生在模拟器和我的设备上。
func setupUI() {
self.view.backgroundColor = UIColor.whiteColor()
// Required to properly display searchbar within nav & tabbar controllers
self.extendedLayoutIncludesOpaqueBars = true // have tried setting this to false as well
self.definesPresentationContext = true
self.searchResultsController = AppDelegate.getViewController(ScheduleStoryboard.name, controllerName: ScheduleStoryboard.Identifiers.foodSearchResults) as? SearchResultsController
self.searchController = UISearchController(searchResultsController: searchResultsController)
self.searchController.searchResultsUpdater = self
self.searchController.delegate = self
self.searchController.dimsBackgroundDuringPresentation = true
self.searchController.searchBar.delegate = self
self.searchController.searchBar.placeholder = "Search foods..."
self.searchController.searchBar.setBackgroundImage(UIImage(named: "background-searchbar")?.resizableImageWithCapInsets(UIEdgeInsetsMake(0, 0, 0, 0)), forBarPosition: .Any, barMetrics: .Default)
self.searchController.searchBar.tintColor = UIColor.whiteColor()
self.searchController.searchBar.sizeToFit()
// this headerView does NOT belong to the tableView, its anchored on top of the tableView so that the searchbar remains fixed when scrolling
self.headerView.addSubview(searchController.searchBar)
self.tableView.delegate = self
self.tableView.dataSource = self
self.tableView.tableHeaderView?.backgroundColor = UIColor.clearColor()
self.tableView.tableHeaderView?.addBorder(.Bottom, color: UIColor.groupTableViewBackgroundColor(), width: 0.25)
self.segmentedControl.tintColor = UIColor.genioBlue()
}
这里是视频的链接,显示正在发生的事情:http://sendvid.com/xgq81stx
谢谢!
【问题讨论】:
-
您找到解决方法了吗?我面临着完全相同的问题
-
对我来说也是同样的问题。我也没有找到解决办法。
-
你在模拟器上测试它吗?或在您的 iPhone 或 iPad 上?模拟器通常是错误的,所以可以连接一个实际的设备来尝试一下。希望有帮助!如果有,请告诉我。
-
还是同样的问题?我有完全相同的问题。第一次之后,一切顺利。
-
我不知道这个错误的真正原因是什么,但就我而言,这是因为我在
searchResultsControllertableView 中添加了一个UIRefreshControl。删除它,不再有慢动画。
标签: ios swift uisearchbar uisearchcontroller