我创建了一个弹出窗口,显示一个列表,我将文本发送到另一个viewcontroller,但是当我关闭弹出窗口时,导航项目消失了,我已经搜索了什么来解决这个问题。在弹出窗口中发送所选列表项的代码是:
Shared.shared.filialNome = self.filiais[indexPath.row].razaoSocial
self.recebeCodigo = self.filiais[indexPath.row].codigo
Shared.shared.codigoFilial = self.recebeCodigo
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "AniversarioViewController") as! AniversarioViewController
self.present(newViewController, animated: true, completion: nil)
以下类型=模态 我试图将Present称为Popover,但错误仍然存在,似乎它没有完全关闭VC,有人可以帮助我。
答案 0 :(得分:0)
看起来像是在呈现视图控制器(而ViewControllers在我们将其嵌入导航控制器之前没有导航项)。 因此,您可以在故事板中的导航控制器中嵌入相同的ViewController,然后获取该导航控制器的参考并显示导航控制器,如
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let navController = storyBoard.instantiateViewController(withIdentifier: "YourNavigationControllerIdentifier") as! UINavigationController
self.present(navController, animated: true, completion: nil)
或者,如果您不想嵌入,您可以通过编程方式执行
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "AniversarioViewController") as! AniversarioViewController
let navController = UINavigationController.init(rootViewController: newViewController)
self.present(navController, animated: true, completion: nil)