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. But the back button will navigate you to all the previous viewcontrollers. But none of them is present there in the navigation stack.Is there any change in the navigation handling in ios8?
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?
Edit:
In the prepareForSegue:, I am using the following code:
if([[segue identifier] isEqualToString:@"mediaDetailSegue1"])
{
MovieDetailViewController *movieDetail;
if(isIOS8SystemVersion)
{
movieDetail = ([[segue destinationViewController]viewControllers][0]);
}
else
{
movieDetail = [segue destinationViewController];
}
movieDetail.videoData = [_mediaContentArray objectAtIndex:selectedIndex];
}
so for iOS versions greater than 8,the code
movieDetail = ([[segue destinationViewController]viewControllers][0]);
is called. I think this is causing the issue. Am I doing it wrong?