【发布时间】:2016-04-10 15:22:35
【问题描述】:
我正在为我的应用程序推送 1.1 更新,但我无法让 UISearchBar 在 iOS 9 中显示和处理我的 ViewController。该应用程序的编写速度很快。
这里是 ListViewController
似乎无论我添加什么都不会显示。我已经尝试了许多教程。 拉动刷新挂起也有问题。 谢谢:)
【问题讨论】:
标签: ios swift uisearchcontroller
我正在为我的应用程序推送 1.1 更新,但我无法让 UISearchBar 在 iOS 9 中显示和处理我的 ViewController。该应用程序的编写速度很快。
这里是 ListViewController
似乎无论我添加什么都不会显示。我已经尝试了许多教程。 拉动刷新挂起也有问题。 谢谢:)
【问题讨论】:
标签: ios swift uisearchcontroller
欢迎来到 StackOverflow,奥斯汀!如果没有更多信息,很难提供帮助,但我会尝试一下。您是要添加 searchBarController 还是 searchBar。许多更现代的应用程序将搜索栏放在导航栏中。这是执行此操作的代码:
将UISearchBarDelegate 添加到类(在 : 之后)。
创建这个变量:lazy var searchBar = UISearchBar(frame: CGRectMake(0, 0, 0, 0))
将此代码添加到您的 viewDidLoad:
searchBar.delegate = self
searchBar.placeholder = "Search"
navigationItem.titleView = searchBar
然后您可以将代码添加到方法func searchBarSearchButtonClicked(searchBar: UISearchBar){ } 和方法func searchBarCancelButtonClicked(searchBar: UISearchBar) { }
对于刷新控件:在刷新函数的最后,调用self.refreshControl!.endRefreshing()
【讨论】: