0
votes

Suppose i have 3 view controllers. I initiate vc1 in vc0 and then vc2 in vc1. Now i want vc2 to be dismissed and after that only vc0 should be shown behind it. How's that possible? I read something about delegate declaration. But couldn't understand.

I have UISegmentcontrol where i'm displaying a controller from storyboard like - vc0 = [self.storyboard instantiateViewControllerWithIdentifier=@"vc0"]; and making it a subview of it [self.view addSubview:vc0.view]; Vc0 is a tableView, which has a detailcontroller to be presented. When i tap on a cell, it shows detailview, but actual segmentcontrol.view is lost when detailview is dismissed.

An example would be awesome.

PS: I'm not using segue for the viewControllers. Instead, i'm using presentModalViewController and dismissModalViewController.

1
vc1 and vc2 are both presented modally at the same time?Wain
Did you want to dismiss all the view controllers at once?Deepak Khiwani
from vc0, vc1 is presented and then vc2 from vc1. I want to go directly to vc0 from vc2. Possible?Monis Manzoor

1 Answers

0
votes

In iOS 5 you need to do

[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]

As of iOS 6 dismissModalViewControllerAnimated: is deprecated.

You need to call

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{ // Do something on completion}] 
//If you want to perform something while going through views or other wise keep completion to nil as shown in below code.

or

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];

or

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];