当前位置:  开发笔记 > 编程语言 > 正文

UISearchController搜索栏动画第一次很慢

如何解决《UISearchController搜索栏动画第一次很慢》经验,为你挑选了0个好方法。

在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

谢谢!

推荐阅读
李桂平2402851397
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有