In my project, I used the 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 get the desired result. But for iOS version 8.2, the value in the VC of the changed arrays is only the current one or topViewController on the stack. But the back button will take you to all previous view controllers. But not one of them is present there in the navigation stack. Are there any changes to navigation handling in ios8?
I want to remove the login screen view manager from the stack so that when I click the back button, it will not return to the login screen. I encountered this problem only in iOS 8.2 (maybe in iOS 8 and above). What could be the problem?
Edit:
In prepareForSegue:, I use 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]; }
therefore, for iOS versions exceeding 8, the code
movieDetail = ([[segue destinationViewController]viewControllers][0]);
. I think this is causing the problem. Am I doing it wrong?
source share