Vipul J
Vipul J

Reputation: 6691

iOS : Is there a way to kill current view controller of NavigationControl before navigating to other view controller?

For example current viewcontroller in Navigation Controller is 'A'. Now before or just after navigating to 'B' from 'A', I want to kill 'A'. Is there a way for such a mechanism ?

Upvotes: 1

Views: 1460

Answers (1)

HackyStack
HackyStack

Reputation: 5157

Sure, do something like this:

NSMutableArray *vcArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];
[vcArray removeObjectAtIndex: 0];  
self.navigationController.viewControllers = vcArray;
// don't forget to release vcArray if you aren't using ARC

Upvotes: 1

Related Questions