在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
谢谢!