iphone、ipad 导航控制器 popToViewController 无法正常工作
我实现了一个导航控制器,它有 10 多个视图。在这里,通过在视图中向右滑动来切换到下一个视图...向左滑动将带您进入上一页。在这里我使用 poptoviewcontroller 来转到上一页。
每个页面都有一个菜单可以切换到所需的视图。跳转到特定视图后,如果我们向左滑动将带来以前访问过的视图,而不是这个,我只想按照菜单转到上一页...
这里我使用了 poptoviewcontroller 的所有属性,但它没有任何建议。
谢谢,
i implemented a navigation controller which has 10+ view.. here by swiping right in view am switching to the next view... swiping left will bring u the previous page. here i used poptoviewcontroller for go to prevous page.
in each of every page it has a menu to switch over to desired view. after jumping to the particular view if we swiping left will brings previously visited view instead of this i just want to go the previous page as per the menu...
here i used all the property of poptoviewcontroller but it doest work any suggestion.
thnks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须将导航的视图控制器视为一个堆栈(就像办公桌上的一叠纸)。
因此,如果将某些内容推入堆栈,那么当您从堆栈中弹出某些内容时,它将是前一项。
我不确定你在做什么,但我会看看 UINavigationController 的 setViewController:Animated 方法的文档。我想这会对你的问题有所帮助。
You have to think of the Navigation's view controllers as a stack (like a stack of papers on you desk).
So, if push something on to the stack, when you pop something off the stack, it'll be the previous item.
I'm not sure what you're doing, but I would look at the documentation for UINavigationController's setViewController:Animated method. I think it'll help with your problem.
让我解释一下什么是 nvaigationcontroller 堆栈。
堆栈 = {根,A,B,C,D}。
当前可见视图是D。当你使用pushViewController(E)时,意味着你向堆栈中添加了一个新视图,该视图变得可见:Stack = {root, A, B, C, D, E}。当您创建 popViewController 时,您删除了堆栈的最后一个元素并将新的最后一个元素设置为可见,在我们的例子中,它再次变为:Stack = {root, A, B, C, D} 并且 D 可见。
现在,如果您选择 popToRootController(A),则意味着您从堆栈中删除所有元素,直到顶部元素为 A 并且它变得可见,因此在我们的例子中它是 Stack = {root, A}。
我希望我正确理解你的问题并向你解释,以便你能够正确理解层次结构。如果没有,请重新表述您的问题。
Let me explain you what is nvaigationcontroller stack.
Stack = {root, A, B, C, D}.
The current visible view is D. When you make pushViewController(E) is means that you added a new view to the stack, which becomes visible: Stack = {root, A, B, C, D, E}. When you make popViewController you deleted the last element of the stack and set the new last element to be visible, in our case it becomes : Stack = {root, A, B, C, D} again and D is visible.
Now if you choose popToRootController(A) it means you remove all the elements from the stack untill the top element is A and it becomes visible so in our case it's Stack = {root, A}.
I hope I understood correctly your question and explained you so that you could understand correctly the hierarchy. If not, please reformulate your question.
最后我解决了这个问题。但实际上没有使用 setViewController 方法。
在这里,当推送视图本身时,我将视图添加到堆栈中。例如,我想要转到视图 A 到 D 意味着我添加了 b 和 c,并使用 PushViewController 动画:NO;和 D 带有动画:是;
所以它对我来说非常有效......
finally i solved this issue. but not using setViewController method infact.
here while pushig the view itself i added the views in stack. ie for example i want go to the view A to D means i added b and c with pushviewcontroller animated:NO; and D with animated:YES;
So it worked perfectly for me....