Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-23-2011, 05:32 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 103
TheRekz is on a distinguished road
Default dismiss modalViewController from a view controller not working

So let me give an overview of the setup I have first. I have a UITabBarController with three tabs, each tab is a UINavigationController. In the third tab I have a UINavigationController with a rootViewController. I then was able to push another view controller to the UINavigationController, lets say that this view controller that is pushed is referred as 'Y'. In this Y view controller I am also capable of showing a modal view controller. So I did:

Code:
[self presentModalViewController:login animated: YES]
where login here is just another UIViewController. I can present the modal view controller just fine, and when I try to dismiss it I do

Code:
[self dismissModalViewControllerAnimated:YES];
However, this does not dismiss the modalviewcontroller (I checked and this is actually called). So what is the solution to this?
TheRekz is offline   Reply With Quote
Old 09-23-2011, 06:07 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by TheRekz View Post
So let me give an overview of the setup I have first. I have a UITabBarController with three tabs, each tab is a UINavigationController. In the third tab I have a UINavigationController with a rootViewController. I then was able to push another view controller to the UINavigationController, lets say that this view controller that is pushed is referred as 'Y'. In this Y view controller I am also capable of showing a modal view controller. So I did:

Code:
[self presentModalViewController:login animated: YES]
where login here is just another UIViewController. I can present the modal view controller just fine, and when I try to dismiss it I do

Code:
[self dismissModalViewControllerAnimated:YES];
However, this does not dismiss the modalviewcontroller (I checked and this is actually called). So what is the solution to this?
A modal view controller does not dismiss itself. You have to send the dismiss call to the original view controller that you pushed the modal onto.

Inside the modal view controller, I believe that the parentViewController property will point to the view controller that "owns" the modal view controller. So, from code inside the modal, you should be able to use code like this:

Code:
[self.parentViewController dismissModalViewControllerAnimated:YES];
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-23-2011, 06:34 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 194
mavrik5150 is on a distinguished road
Default

It could also be how you are presenting the modal view since you said you have a TabBar as well you may want to try:

[self.tabBarController presentModalViewController:login animated:YES];

If Duncan's method doesn't work you may want to try this. I have a TabBar app and this is how the Modal Views are presented and then the Modal Views can dismiss themselves (I just use the same code you did with the IBAction of a Close Button being pushed).
mavrik5150 is offline   Reply With Quote
Old 09-23-2011, 06:52 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Actually Duncan, it does work. If you call dismiss on the modal view controller (the one that was presented), it will work. It's just proper to have the vc that presented it dismiss it as well.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 09-23-2011, 06:56 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 22
bartender is on a distinguished road
Default

You could add a button like this..

Code:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewControllerAnimated:)];
    loginviewcontroller.navigationItem.backBarButtonItem = doneButton;
bartender is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 394
15 members and 379 guests
13dario13, 7twenty7, eski, EvilElf, glenn_sayers, HemiMG, iOS.Lover, jarv, n00b, pbart, Pudding, sacha1996, Sami Gh, UMAD, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,905
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0