侧边菜单覆盖特定情况的后退按钮
Posted
技术标签:
【中文标题】侧边菜单覆盖特定情况的后退按钮【英文标题】:Side Menu override back button for specific cases 【发布时间】:2017-10-23 19:15:41 【问题描述】:我正在使用https://github.com/jonkykong/SideMenu 它工作正常,但是,我想覆盖堆栈。
比如我有下一个流程?:
HomeViewController
> MyBusinessViewController
> TheBusinessXViewController
> Add CategoryViewController
> MyBusinessViewController
(再次)。
但是,当我回到MyBusinessViewController
时,Back Button
正在重定向到以前的ViewController
,但我想删除所有堆栈并在那里有初始菜单(就像HomeViewController
)
这可能吗?
要有更自然的行为。
【问题讨论】:
您可以在准备再次导航到MyBusinessViewController
时设置导航堆栈的viewControllers
属性,以便viewControllers
属性仅包含两个数组(HomeViewController > MyBusinessViewController)
【参考方案1】:
要将Add CategoryViewController
排除在流程中,我们需要考虑以下内容:
Add CategoryViewController
完成后,您希望拥有:
HomeViewController
> MyBusinessViewController
> TheBusinessXViewController
TheBusinessXViewController
将是要显示的控制器,然后:
let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "TheBusinessXVC") as! TheBusinessXViewController
nextVC.id = self.idtruck
nextVC.extraparameter = "StringOrInt"
let newViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeVC") as! HomeViewController
let sencondViewController = self.storyboard?.instantiateViewController(withIdentifier: "MyBusinessVC") as! MyBusinessViewController
let customViewControllersArray : NSArray = [newViewController, sencondViewController, nextVC]
self.navigationController?.viewControllers = customViewControllersArray as! [UIViewController]
self.navigationController?.pushViewController(nextVC, animated: true)
【讨论】:
以上是关于侧边菜单覆盖特定情况的后退按钮的主要内容,如果未能解决你的问题,请参考以下文章
调用 pushViewController 时,后退按钮会覆盖上一个 UIBarButton
如何在flutter中停用或覆盖appBar中的箭头后退按钮?