UISearchController 类似于 Apple 地图

UISearchController like Maps of Apple

我正在使用 Objective C 开发 iOS 应用程序。 我实现了 UISearchController ,它工作正常我只是想像苹果地图但导航栏上的按钮并没有消失 这是一些截图。

有什么想法吗?!

Before click

After click

试试这样使用UISearchBar的delegate方法

在开始编辑 UISearchBar 时,像这样删除导航按钮

func searchBarShouldBeginEditing(searchBar: UISearchBar) -> Bool {
    self.navigationItem.leftBarButtonItem = nil
    self.navigationItem.rightBarButtonItem = nil
    return true
}

在取消按钮上再次单击添加导航按钮

func searchBarCancelButtonClicked(searchBar: UISearchBar) {
    //Add the code you are using to previously set navigation with buttons and UISearchBar
}

希望对您有所帮助。