1

Currently my scenario like this ,

View Controller(VC1)  -->  Push Segue --> View Controller(VC2)
          |                                   ^ 
          | Model Segue                       |
          |                                   | Push Segue
          |-----> View Controller(VC3)  ------|         

Now in VC3 when i push in to VC2 i want to dismiss VC3 view Controller and on after VC2 back button it should be VC1's back view controller i want to pop VC3

What i want is i want to remove VC3 when i push the VC2 from VC3 when we back then it VC1 should appear

Check Example

I have done like this can anyone help me out

View Controller (VC3) :

- (void)callWebservice {

   [self dismissViewControllerAnimated:YES completion:^{

         [self performSegueWithIdentifier:@"showVC2" sender:self];
   }];

}

Thanks in advance

2 Answers2

0

I think you are looking for https://stackoverflow.com/a/21415225/1320305 if you are using segue, to do this manually try following:

you can try this

 // locally store the navigation controller since
 // self.navigationController will be nil once we are popped
 UINavigationController *navController = self.navigationController;

 // retain ourselves so that the controller will still exist once it's popped off
 [[self retain] autorelease];

 // Pop this controller and replace with another
 [navController popViewControllerAnimated:NO];//not to see pop

 [navController pushViewController:aViewController animated:YES];
//to see push or u can change it to not to see.

OR try this

UIViewController *newVC = [[UIViewController alloc] init]; // Replace the current view controller 
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:[[self navigationController] viewControllers]];
[viewControllers removeLastObject]; 
[viewControllers addObject:newVC]; 
[[self navigationController] setViewControllers:viewControllers animated:YES];
Community
  • 1
  • 1
a4arpan
  • 1,828
  • 2
  • 24
  • 41
0

I think you can implement in that way:

  • when you at screen 3 you want push screen 2. You will dismiss screen 3 and call a delegate back screen 1.
  • And from screen1 you will push view to screen2.

You can see my demo for my idea: Demo Pushview Swift

DemoPushViewObj

vien vu
  • 4,277
  • 2
  • 17
  • 30
  • can u do in objective C? –  Dec 10 '15 at 09:35
  • @BlackCop It's ok. Wait me I will give you demo in Objetive-c. – vien vu Dec 10 '15 at 09:37
  • Yes i can see that but my scenario different from you check demo http://s000.tinyupload.com/index.php?file_id=69811463087160928732 –  Dec 10 '15 at 10:00
  • @BlackCop ah I see. You want push. I have modified code in this case. Check it. – vien vu Dec 10 '15 at 10:06
  • it's working but a one issue there when we r going to push from VC3 to vc2 then a little bit timt VC1 is showing how to hide that problem ? –  Dec 10 '15 at 10:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97507/discussion-between-black-cop-and-vien-vu). –  Dec 10 '15 at 10:35