Using multiple ModalViewController
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.
- Dismissing viewControllerA before presenting ViewControllerB // which directly going to view C
- Dismissing viewControllerA in viewControllerB // No results. //DismissViewController should dismiss all stack.. but not working for me so I tried
- Dismissing both viewContrller i开发者_运维知识库n viewControllerB //still it shows viewContrllerA
OMG...it's confusing..
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.
Here is what I did.. not a good solution but works for now.. :)
///ViewDidLoad [self presentModalViewController:ViewControllerA animated:YES];//Working fine
//inside ViewController A [self dismissModalViewControllerAnimated:NO];
//ViewWillAppear [self presentModalViewController:ViewControllerB animated:YES];//Working fine
//inside ViewController B [self dismissModalViewControllerAnimated:NO];
精彩评论