【问题标题】:Navigation bar disappears while navigating back from search page to home page using SWreveal view cntroller in swift 3?在swift 3中使用SWreveal视图控制器从搜索页面导航回主页时导航栏消失?
【发布时间】:2018-11-23 18:46:56
【问题描述】:

在这里,我在主页中有导航栏,即前视图控制器,在主页中,我在导航中也有导航栏和搜索栏,点击搜索栏后,它会移动到没有任何导航的搜索页面,如果我关闭从搜索页面主页导航消失,谁能帮我在 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)
}

【问题讨论】:

  • 您是否隐藏在搜索页面导航栏中的任何位置
  • 是的,在搜索页面中我不需要任何导航栏,所以我隐藏了导航栏@Anbu.karthik

标签: ios swift3 uinavigationbar swrevealviewcontroller


【解决方案1】:

如果您需要在 ViewController(VC) 上隐藏或显示导航栏,您只需在“viewWillAppear”和“viewWillDisappear”函数中执行此操作

在您的家庭 VC 上,添加以下行

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)

    self.navigationController?.setNavigationBarHidden(false, animated: true)
}

或在您的搜索页面视图中WillDisappear 启用导航栏

 override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

// Show the Navigation Bar
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多