Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i pop to Specific ViewController?

I am using navigation based application. I push First ViewController to Second ViewController and from Second ViewController to Third ViewController. Now I want to pop from Third ViewController to First ViewController.I am performing this task using the below code but my application crashed.

Please any body give me some proper guidelines. I can't use pop to rootViewController because it's different viewController. Thanks in advance...

In Third ViewControler i have written this:

FirstViewCtr *x=[[FirstViewCtr alloc] initWithNibName:@"FirstViewCtr" bundle:nil]; [self.navigationController popToViewController:x animated:NO]; 
like image 524
Ankit Vyas Avatar asked Jun 12 '10 05:06

Ankit Vyas


People also ask

How do I pop two viewControllers at a time in Swift?

There's also a setViewControllers(_:animated:) to include the pop animation. Alternatively you could find the second last view controller in the viewControllers array and then use popToViewController to avoid overwriting the entire view controller stack.

How do I change ViewController?

Click on the controller name that you want to change. Inside the class right-click on the class name of the controller. Now you'll be able to see REFACTOR option. Click on the refactor you can get RENAME option.


1 Answers

By Writing the First Line you get the Indexes of all View Controllers and from second Line You will reach up to your Destination.

NSArray *array = [self.navigationController viewControllers];  [self.navigationController popToViewController:[array objectAtIndex:2] animated:YES]; 
like image 89
Ankit Vyas Avatar answered Sep 22 '22 13:09

Ankit Vyas