代码之家  ›  专栏  ›  技术社区  ›  Xcoder

导航控制器为零,但嵌入在视图控制器中

  •  0
  • Xcoder  · 技术社区  · 6 年前

    Storyboard

    如您所见,我的导航控制器嵌入在根视图控制器中。在这个视图控制器中,我有一个子视图,有一次,我将popover推到视图控制器上。由于某种原因,我不能使用 navigationController.popViewController(animated: true) 因为导航控制器是nil(通过将值打印到调试控制台)。我怎样才能解决这个问题?

    2 回复  |  直到 6 年前
        1
  •  1
  •   ielyamani    6 年前

    使用 dismiss(animated flag: Bool, completion: (() -> Void)? = nil) . 从popover视图控制器调用它:

    self.dismiss(animated: true) 
    
        2
  •  0
  •   Anton    6 年前

    self.present(popover, animated: true, completion: nil)
    

    你可以在popover中忽略它

    self.dismiss(animated: true) 
    

    如果你把popover推到导航控制器上

    self.navigationController?.pushViewController(popover, animated: true)
    

    你可以使用

    self.navigationController?.popViewController(animated: true)