Skip to content

UINavigationController cann't work fine #42

Closed
likid1412 opened this Issue Apr 11, 2013 · 1 comment

2 participants

@likid1412

I use a UINavationController to push the first view controller, and then show the second one with this animation, when I tap the dismiss button(created by myself), it crashed!! So, I fixed it.
// This method doesn't suppose UINavigation model

  • (id) traverseResponderChainForUIViewController { id nextResponder = [self nextResponder]; BOOL isViewController = [nextResponder isKindOfClass:[UIViewController class]]; BOOL isTabBarController = [nextResponder isKindOfClass:[UITabBarController class]]; BOOL isNavController = [nextResponder isKindOfClass:[UINavigationController class]]; // Add this if (isViewController && !isTabBarController && !isNavController) { return nextResponder; } else if(isTabBarController){ UITabBarController *tabBarController = nextResponder; return [tabBarController selectedViewController]; } else if (isNavController) { // get the last but one, it should be last view controller for the showing view. UINavigationController *nav = nextResponder; UIViewController *lastButOne = nav.viewControllers[nav.viewControllers.count - 2]; NSLog(@"array:%@, \n%@",nav.viewControllers, lastButOne); return lastButOne; } else if ([nextResponder isKindOfClass:[UIView class]]) { return [nextResponder traverseResponderChainForUIViewController]; } else { return nil; } }

The core code is this:
else if (isNavController)
{
// get the last but one, it should be last view controller for the showing view.
UINavigationController *nav = nextResponder;
UIViewController *lastButOne = nav.viewControllers[nav.viewControllers.count - 2];
NSLog(@"array:%@, \n%@",nav.viewControllers, lastButOne);
return lastButOne;
}

@kentnguyen
Owner

Please learn to format and create a proper ticket with full context (iOS version, device, specific use case)

@kentnguyen kentnguyen closed this Apr 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.