0

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.

Brian Sachetta
  • 3,319
  • 2
  • 34
  • 45
abhimuralidharan
  • 5,752
  • 5
  • 46
  • 70
  • Can you please NSLog self.navigationController.viewControllers and update the questio. It will help us to identify the issue somehow. – Jassi Apr 04 '15 at 12:32
  • Thank you jassi for your time...The content of the viewcontroller array is only the current viewcontroller if the os is 8.2...if it is 7.2,then all the viewcontrollers are there in the stack.I dont have the device currently with me.sorry...Any idea why this is happening.? – abhimuralidharan Apr 04 '15 at 13:12
  • Did you ever solve this problem? – Hussein Jun 17 '16 at 12:56

1 Answers1

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!

childrenOurFuture
  • 1,889
  • 2
  • 14
  • 23