问题
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];
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.
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.
回答1:
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!
来源:https://stackoverflow.com/questions/29446016/how-to-handle-the-back-buttonios-8-2-in-iphone