I have a problem with iPhone App using UINavigationController. When I use pushNavigationController, it works fine. The iPhone does its animation by switching to the next ViewController. But when using the ViewControllers array and the setViewControllers method, it crashes in the animation, which can grow into a clearly visible animation error.
The following snippet is called in the root ViewController. Depending on the state, it should either switch to ViewController1, or it should go directly to ViewController2. In the latter case, the user can return to vc1, and then to the root.
NSMutableArray* viewControllers = [NSMutableArray arrayWithCapacity:2];
[viewControllers addObject:self];
AuthentificationViewController* authentificationViewController =
[[[AuthentificationViewController alloc] initWithNibName:@"AuthentificationViewController" bundle:nil] autorelease];
[viewControllers addObject:authentificationViewController];
if (someCondition == YES)
{
UserAssignmentsListViewController* userAssignmentsListViewController =
[[[UserAssignmentsListViewController alloc] initWithNibName:@"UserAssignmentsOverviewViewController" bundle:nil] autorelease];
[viewControllers addObject:userAssignmentsListViewController];
}
[self.navigationController
setViewControllers:[NSArray arrayWithArray:viewControllers] animated:YES];
, , , VC , navigationController . , . , , "". , . , , , . .
pushViewController, / . , , pushViewController. , VC, . , ? pushNavController VC2, - VC1 , .
.: -)
: iOS 4.2, 4.0.