Ios 我怎样才能清理UINavigationBar的历史?
目前,我有一个带有Ios 我怎样才能清理UINavigationBar的历史?,ios,swift,uitableview,uinavigationcontroller,segue,Ios,Swift,Uitableview,Uinavigationcontroller,Segue,目前,我有一个带有UINavigationBar的家长“菜单”TableView,从每个单元格有一个由参考插座到3个具有不同信息的类似视图的序列 在每个视图中都有一个按钮连接到其他两个视图 使用每个按钮的segue打开另一个视图 问题是: 从每个视图
UINavigationBar
的家长“菜单”TableView
,从每个单元格
有一个由参考插座
到3个具有不同信息的类似视图的序列
在每个视图中
都有一个按钮
连接到其他两个视图
使用每个按钮
的segue打开另一个视图
问题是:
从每个视图
的后退按钮
将我返回到上一个视图
,但我尝试将后退按钮
切换到“菜单”
附加的Bar按钮项
和它的分段效果非常接近,但分段动画与UINavigationController
不同
如何清理从“初始视图”到“初始视图”的过程中的UINavigationBar转换历史?您可以尝试弹出到根视图控制器,也可以编辑导航控制器
视图控制器
属性,并在两者之间删除/添加一些VC
您也可以尝试使用解卷顺序机制。以下是导航控制器为pop操作提供的一些方法(功能)。他们从弹出的导航堆栈返回可选的UIViewController(intance)
open func popViewController(animated: Bool) -> UIViewController? // Returns the popped controller.
open func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? // Pops view controllers until the one specified is on top. Returns the popped controllers.
open func popToRootViewController(animated: Bool) -> [UIViewController]?
以下是用于解决您的查询的示例代码:
// if you want to back to root of your app
if let rootNavigationController = self.window?.rootViewController as? UINavigationController {
rootNavigationController.popToRootViewControllerAnimated(true)
}
// But if you want to back to root of your current navigation
if let viewcontroller = self.storyboard?.instantiateViewController(withIdentifier: "NewViewController") as? NewViewController { // or instantiate view controller using any other method
viewcontroller.navigationController?.popToRootViewControllerAnimated(true)
}
我想您正在寻找从pop到root的视图控制器(动画:)