Xavi Valero
Xavi Valero

Reputation: 2057

Viewcontrollers missing from the navigation stack

I am having a strange problem, that when executing one method and my viewcontrollers in the navigation stack goes missing. In the following piece of code, I log the viewcontroller count in the navigation stack. I am also logging the viewcontrollers in the navigation stack.

NSMutableArray *navigationarray = [[NSMutableArray alloc]initWithArray:self.navigationController.viewControllers];
NSLog(@"Navigation array %@", navigationarray);
NSLog(@"Navigation array count %d", [navigationarray count]);

[self.doneButton.target performSelector:self.doneButton.action withObject:self.doneButton.target];

NSMutableArray *navigationarrayOne = [[NSMutableArray alloc]initWithArray:self.navigationController.viewControllers];
NSLog(@"Navigation array %@", navigationarrayOne);
NSLog(@"Navigation array count %d", [navigationarrayOne count]);

Before the method is called, the navigation stack has 3 viewcontrollers. But after the method is executed, there are no viewcontrollers in the navigation stack. I have put a breakpoint in the dealloc method of the 3 viewcontrollers and found that viewcontrollers are not being deallocated. What could be the reason for this?

The current class subclasses ABNewPersonViewController..and self.doneButton.action executes

- (void)newPersonViewController:(ABNewPersonViewController *)newPersonViewController
   didCompleteWithNewPerson:(ABRecordRef)person;

method in a class that subclasses ABPersonViewController

Upvotes: 0

Views: 610

Answers (1)

Jeffery Thomas
Jeffery Thomas

Reputation: 42588

navigationController is shared by all views in that stack. Any of them can set the value of navigationController.viewControllers. Look to see if your new view controller is making changes to the navigation stack.

Upvotes: 1

Related Questions