ios上没有屏幕的历史记录 [英] No history for a screen on the ios

查看:77
本文介绍了ios上没有屏幕的历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用monotouch来开发ios应用程序.假设我有3个屏幕:s1,s2和s3.用户可以这样打开它们:s1-> s2-> s3.

I'm using monotouch for developing ios applications.Suppose that I have 3 screens: s1, s2 and s3. User can open them like this: s1 -> s2 -> s3 .

我希望如果用户打开s2,可以通过向后导航按钮返回到s1屏幕,但是如果通过在导航栏中按向后按钮返回到s3屏幕,则应用程序将返回到s1 no s2.

I want that if user open s2 it can back by navigation back button to the s1 screen, but if it goes to the s3 screen by pressing back button in the navigation bar the application back to the s1 no s2.

在iOS中有可能吗?在android上,如果您使用NoHistory属性,则可以实现此功能,ios中也有等效功能吗?

Is it possible in the ios? On the android if you use NoHistory attribute you can implement this feature, is there any equivalent in the ios too?

推荐答案

您可以在navigationController中手动编辑视图控制器以删除s2.

You can manually edit the view controllers in your navigationController to remove s2.

您可以使用self.navigationController.viewControllers获取当前堆栈,并使用[self.navigationController setViewControllers:animated:]设置堆栈.

You can use self.navigationController.viewControllers to get the current stack, and [self.navigationController setViewControllers:animated:] to set the stack.

您可能需要这样做:

NSMutableArray *views = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
[views removeObjectAtIndex:1];
[self.navigationController setViewControllers:views animated:NO];

如果在s3 viewController中调用它,它将在堆栈上获取viewControllers,删除第二个(位于索引1的对象),并将其设置为新堆栈.动画:否,就是制作它,使其无需动画即可立即完成.

If you call this in your s3 viewController, it will get the viewControllers on the stack, remove the second one (object at index 1), and set them as the new stack. animated:NO just makes it so that it does it instantly without animation.

请注意,您可能希望更改此代码行,以便在没有s2的情况下到达s3时,它不会弹出s3.另外,如果s2和根目录之间存在另一种视图,则要删除的视图可能不是objectAtIndex:1.

Be aware that you might want to change this line of code so that if you ever get to s3 without s2 being before it, it does not pop s3. Also if there is another view between s2 and the root, the one you want to remove might not be objectAtIndex:1.

这篇关于ios上没有屏幕的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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