views:

46

answers:

1

Starting a new thread... about same question.. I have tried all I am getting from different post and forums... none of the working for me..

What I want to do is...

[self presentModalViewController:ViewControllerA animated:YES];//Working fine
//Inside viewControllerA call viewControllerB
[self presentModalViewController:ViewControllerB animated:YES];//Working fine
//Dismiss both the Controllers. and present View

C

I tried.

  1. Dismissing viewControllerA before presenting ViewControllerB // which directly going to view C
  2. Dismissing viewControllerA in viewControllerB // No results. //DismissViewController should dismiss all stack.. but not working for me so I tried
  3. Dismissing both viewContrller in viewControllerB //still it shows viewContrllerA

OMG...it's confusing..

+1  A: 

Your code is unclear (you're using self twice when they probably refer to different things). I'm assuming what you want to do is (effectively) this:

[viewController presentModalViewController:viewControllerA animated:YES];
// time passes...
[viewControllerA presentModalViewController:viewControllerB animated:YES];
// time passes
... do something to dismiss both controllers ...

You might have luck with something like this:

[viewControllerA dismissModalViewController:NO];
[viewController dismissModalViewController:NO];

I'm not sure what you mean by "in" or "inside"; it doesn't matter what class you're "in". But generally, a view controller is responsible for its children. Typically, the parent sets itself as the delegate of the child. When the child is "done", it sends a message to the parent; the parent is responsible for dismissing the child. UIKit's prepackaged view controllers (UIImagePickerController/MFMailComposeViewController/MFMessageComposeViewController) all follow this pattern.

tc.
if I use viewController instead of self to presentModalViewController... it's not presenting view... here is how I am creating viewControllerA..... ViewControllerA *viewControllerA = [[[ViewControllerA alloc] init] autorelease];
KiranThorat
I'm using viewController to refer to whichever "root" view controller you're using. "self" is meaningless by itself. Sigh.
tc.
Im still tyring...
KiranThorat
When you are saying use viewController instead of self... if I have to present view from current view controller... then I should use self right ??
KiranThorat
Hey it's working not exactly a solution.. but.. I am calling Dismiss viewControllerA before Presenting B... Thanks for help.. I will vote you up.
KiranThorat
What do you mean by "current" - the one that is being displayed, or the receiver of methods your executing? "self" is the latter.
tc.