Pie*_*rre 3 uinavigationcontroller ios uisearchcontroller
我正在尝试使用UISearchController为我的iphone应用程序显示一个简单的搜索屏幕.我使用了UITableViewController和UISearchController,它嵌入在UINavigationController中


我想做的是直接获得状态2而不进入状态1
我试图添加此代码
presentViewController(searchController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
但它要么不显示搜索栏,如果动画是假的,或者显示它我想要但是在不必要的过渡后暂时显示导航栏
好的,我刚刚发现如何在UIViewController中读取这个答案UISearchController
我只需要像这样添加搜索栏以获得所需的效果
searchController.hidesNavigationBarDuringPresentation = false
// tableView.tableHeaderView = searchController.searchBar
navigationItem.titleView = searchController.searchBar
Run Code Online (Sandbox Code Playgroud)