在 swift 3 中使用 SWreveal 视图控制器从搜索页面导航回主页时导航栏消失?
Navigation bar disappears while navigating back from search page to home page using SWreveal view cntroller in swift 3?
我在主页上有导航栏,即前视图控制器,在主页上我也有导航栏和搜索栏,在点击搜索栏后,它会移动到没有任何导航的搜索页面,如果我从搜索页面中删除主页导航消失了谁能帮我如何在 swift 3 中从任何视图控制器返回时如何放置主页导航栏?
下面是我的图片
https://user-images.githubusercontent.com/32094391/41342703-82c64c24-6f1a-11e8-89e9-ebd35066e7d2.png
使用的代码如下所示
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let abcViewController = storyboard.instantiateViewController(withIdentifier: "filterPage") as! filterPageViewController
self.navigationController?.pushViewController(abcViewController, animated: true)
}
从搜索页面返回的代码是
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
self.navigationController?.popViewController(animated: true)
}
If you need to hide or make your navigation bar visible on your ViewController(VC), you simply do that in the “viewWillAppear” and “viewWillDisappear” functions
在您的家 VC 上,添加以下行
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
或在您的搜索页面 viewWillDisappear 中启用导航栏
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show the Navigation Bar
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
我在主页上有导航栏,即前视图控制器,在主页上我也有导航栏和搜索栏,在点击搜索栏后,它会移动到没有任何导航的搜索页面,如果我从搜索页面中删除主页导航消失了谁能帮我如何在 swift 3 中从任何视图控制器返回时如何放置主页导航栏?
下面是我的图片
https://user-images.githubusercontent.com/32094391/41342703-82c64c24-6f1a-11e8-89e9-ebd35066e7d2.png
使用的代码如下所示
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let abcViewController = storyboard.instantiateViewController(withIdentifier: "filterPage") as! filterPageViewController
self.navigationController?.pushViewController(abcViewController, animated: true)
}
从搜索页面返回的代码是
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
self.navigationController?.popViewController(animated: true)
}
If you need to hide or make your navigation bar visible on your ViewController(VC), you simply do that in the “viewWillAppear” and “viewWillDisappear” functions
在您的家 VC 上,添加以下行
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
或在您的搜索页面 viewWillDisappear 中启用导航栏
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show the Navigation Bar
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}