将多个视图控制器推送到导航控制器堆栈时出 [英] Problem pushing multiple view controllers onto navigation controller stack

查看:90
本文介绍了将多个视图控制器推送到导航控制器堆栈时出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将三个视图控制器推到导航控制器上。

I am trying to push three view controllers onto the navigation controller.

  [self.navigationController pushViewController:one animated:YES];
  [self.navigationController pushViewController:two animated:YES];
  [self.navigationController pushViewController:three animated:YES];

所需的行为是视图3将显示,当按下后退按钮时,它将转到查看两个,然后查看一个...

The desired behavior is that view three will show, and when the back button is pressed it will go to view two and then to view one...

实际发生的是视图一个是可见的,然后按回去查看两个然后再返回查看一个。也就是说,显示视图一而不是视图三。

What actually happens is that view one is visible and pressing back goes to view two and then back again it goes to view one. Which is to say that view one is shown instead of view three.

非常奇怪,在上面的调用显示正确的条目后,查看navigationController的viewController数组,并查看 visibleViewController 属性显示它有三个视图...即使查看一个是可见的。

Very strangely, looking at the viewController array of the navigationController after the calls above show the right entries, and looking at the visibleViewController property shows that it has view three in it... even though view one is visible.

如果我从可见视图导航到子视图一个(这显示在视图的位置三)并从该子视图中按回...它会查看三个。

If I navigate to a sub view from the visible view one (that shows in the place of view three) and press back from that sub view... it goes to view three.

它看起来像是显示一个视图,但是知道它在第三视图...

It looks like it is showing view one, but knows it is on view three...

我完全糊涂了......任何想法?

I am completely confused... any ideas?

Jim

推荐答案

对于前两次推送,请不要将动画标志传递为YES,将其设置为NO:

For the first two pushes, don't pass the animated flag in as YES, set it to NO:

[self.navigationController pushViewController:one animated: NO]; 
[self.navigationController pushViewController:two animated: NO];
[self.navigationController pushViewController:three animated: YES];

这将为您提供所需的效果。否则,你会混淆动画系统,因为它试图将三个视图动画到同一个空间。

This will give you the effect you want. Otherwise, you're confusing the animation system, as it tries to animate three views into the same space.

这篇关于将多个视图控制器推送到导航控制器堆栈时出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆