- (void)viewWillDisappear:(BOOL)animated
{
if ([self.navigationController.viewControllers indexOfObject:self] == NSNotFound) {
if ([self.navigationController.viewControllers.lastObject isKindOfClass:[CustomViewController class]]) {
NSArray *tempArr = self.navigationController.viewControllers;
self.navigationController.viewControllers = tempArr;
[self.navigationController popViewControllerAnimated:YES];
return;
}
}
[super viewWillDisappear:animated];
}
if an user press back button and previous UIViewController is CustomViewController then pop 2 last UIViewControllers else pop 1 last UIVIewController.
I think these strings mean nothing:
NSArray *tempArr = self.navigationController.viewControllers;
self.navigationController.viewControllers = tempArr;
But if I delete them then I pop 2 last UIViewControllers and get the title of CustomViewController instead of the title from the current UIViewController.
Is it a bug? And will this code work in iOS 6?