如何处理iPhone中的后退按钮(iOS 8.2) [英] How to handle the back button(iOS 8.2) in iphone

查看:167
本文介绍了如何处理iPhone中的后退按钮(iOS 8.2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我正在使用一些代码来处理后退按钮,如下所示.

In my project, I was using some code to handle the back button as follows.

NSMutableArray *VCs = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
if ([[VCs objectAtIndex:[VCs count] - 2] isKindOfClass:[LoginViewController class]])
{
    [VCs removeObjectAtIndex:[VCs count] - 2];
    [VCs removeObjectAtIndex:[VCs count] - 2];
}
[self.navigationController setViewControllers: VCs];

在iOS 7中,我得到了想要的结果.但是对于iOS版本8.2,可变数组VC中的值只是堆栈中的当前值或topViewController.

In iOS 7 I am getting the desired result. But for iOS version 8.2, the value in the mutable array VCs is only the current or topViewController in the stack.

我想从堆栈中删除登录屏幕视图控制器,以便在单击后退"按钮时不会返回到登录屏幕.我仅在iOS 8.2(可能在iOS 8及更高版本)中面临此问题.可能是什么问题?请帮忙.

I want to delete the login screen viewcontroller from the stack so that on clicking the back button,it will not go back to the login screen. I am facing this issue in iOS 8.2 only (may in iOS 8 and above). What can be the issue? Please help.

推荐答案

是的,我不能就您的观点给出正确的答案.
但是当我查看您的代码时,发现您想在导航堆栈中关闭一些登录viewController.
我的建议是:不要以这种方式显示登录ViewController,就像某种hack代码一样,并且不方便扩展或修改登录工作流程. 不错的选择是将所有登录ViewController置于另一个导航中,以一个登录周期工作.您可以按当前显示导航.
真的方便多了!

Yes, I can not give a right answer to your point.
but when I look into your code, I found you want to dismiss some login viewController in a stack of navigation.
My suggestion is: do not show login ViewController in that way, it's like some kind hack code, and not convenient to expend or modify the login workflow. The good choice is to put all login ViewControllers in another navigation,work in a login cycle. and you can show the navigation by present.
much convenient really!

这篇关于如何处理iPhone中的后退按钮(iOS 8.2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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