0

I have an application that contain three viewcontrollers

Mapview is rootviewcontroller

mapview -pushviewcontroller - listview,

listview - pushviewcontroller - mapview,

1st conditon

mapview -pushviewcontroller - cityview and cityview - pushviewcontroller - mapview

2nd conditon

listview -pushviewcontroller - cityview and cityview - pushviewcontroller - listview

order of viewcontroller like this

mapview-listview, mapview-cityview, listview-cityview

the problem is i am using [self.navigationController popToRootViewControllerAnimated:YES]; but it works only on 1st condition not for 2nd condition when i use this in the 2nd condition it show mapview again

ie. listview pushing successfully to the cityview and i want to pop back to the listview but it back again to the mapview not to the listview

even i also try this [self popToViewControllerAtIndex:1 animated:YES];

but again it shows the same problem.

I have tried pretty much everything I have found in forums.

Thanks in advance!

Nekto
  • 17,837
  • 1
  • 55
  • 65
akshata
  • 41
  • 3

1 Answers1

0

To modify (pop views) navigation stack you can use next methods:

  1. Replaces the view controllers currently managed by the navigation controller with the specified items.

    - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated

  2. Pops the top view controller from the navigation stack and updates the display.

    - (UIViewController *)popViewControllerAnimated:(BOOL)animated

  3. Pops all the view controllers on the stack except the root view controller and updates the display.

    - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated

  4. Pops view controllers until the specified view controller is at the top of the navigation stack.

    - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated

To access current view controllers on the stack you can use @property(nonatomic, copy) NSArray *viewControllers

Community
  • 1
  • 1
Nekto
  • 17,837
  • 1
  • 55
  • 65