返回两个或多个控制器的后退按钮
我知道覆盖后退按钮功能不被认为是一个好的用户设计。然而,我有一个过程,在某些时候回去是没有任何意义的。相反,我希望用户返回两个或更多控制器,
因此在某些 ViewController 中,单击后退按钮应该触发多个 ViewController 的弹出,而不仅仅是前面的一个。我尝试了子类化 NavigationController 并覆盖 popViewController-Method:
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
if([[self.viewControllers lastObject] class] == [MyCOntroller class]){
[super popViewControllerAnimated:NO]; // pop once
return [super popViewControllerAnimated:animated]; // pop twice
} else {
return [super popViewControllerAnimated:animated];
}
}
但是我遇到了问题,NavigationTopBar 不再与前面的 ViewController 同步。有人遇到过同样的问题吗?
I know that overriding the back button functionality is not considered a good user design. However I have process, at which at some point going back would'nt make any sense. Instead I would like the user to go back two or more controller
So within certain ViewControllers, clicking the back-button should trigger the pop of several ViewControllers, not just the one in front. I tried around with subclassing the NavigationController and overriding the popViewController-Method:
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
if([[self.viewControllers lastObject] class] == [MyCOntroller class]){
[super popViewControllerAnimated:NO]; // pop once
return [super popViewControllerAnimated:animated]; // pop twice
} else {
return [super popViewControllerAnimated:animated];
}
}
However I get problems, where the NavigationTopBar is not in sync anymore withe the ViewController being in front. Anybody ran into the same issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该添加左栏按钮。
和
You should add left bar button.
And
另一种方法是从导航堆栈中删除要跳过的视图控制器。在下面的示例中,您返回 2 个视图控制器:
Another way is to delete the viewcontrollers you want to skip from the Navigation stack. In example below, you go back 2 view controllers:
你尝试过使用吗
也许你可以为此类视图控制器自定义后退按钮,然后尝试
Did u try using
Maybe u can have custom back buttons for such view controllers and then try