Reputation: 590
I have a small problem.
I am taking 5 ViewCotrollers A,B,C,D,E. And A is a RootViewcontroller.
In A a have add one button and give it a action. When I click the button the presentModalViewController
called and B ViewController is show. Its addsubView Process. So in all the view same process are their. Means chain process.
But in last view I want to dismiss this presentmodalViewController. And I have tried this type of code.
-(IBAction)Done:(id)sender
{
[self dismissModalViewControllerAnimated:NO];
}
But its not working. Give me proper guidencee.. Thanks..
Upvotes: 2
Views: 635
Reputation: 1911
Try to use notifications like this:
- (void)dismissSelf {
[self dismissModalViewControllerAnimated:YES];
}
- (void)receiveDismissNotification:(NSNotification *) note{
[self performSelectorOnMainThread:@selector(dismissSelf) withObject:nil waitUntilDone:NO];
}
Upvotes: 2
Reputation: 24
make all the view from A to E in the same .xib file....
then in your .h file declare:
UIView *containerView;
and IBOutlets for all View from B to E..
in .m file :
in button Action of your A view you can do this...
containerView= [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[containerView addSubview:BView];
[self.view addSubview:containerView];
this code will add your BView in your rootViewController i.e A...
Now in IBAction of rest views you can write this code to navigate..
[UIView transitionFromView:BviewController toView:CViewController duration:1.0 options:UIViewAnimationOptionTransitionCurlDown completion:nil];
and so on...
to come back to your rootViewController i.e A
[containerView removeFromSuperview];
in IBAction of E view; or you can also use transitionFromView to navigate...
Upvotes: 0
Reputation: 15147
On E View's button event, write this
-(IBAction)Done:(id)sender
{
id mainViewController = [self.view.superview.superview nextResponder];
[mainViewController dismissModalViewControllerAnimated:YES];
}
This code is not tested, but try using this, Hope it works :-)
Upvotes: 1