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-11-2011, 09:51 PM   #1 (permalink)
Beginner iOS Dev
 
Join Date: Feb 2011
Location: Boston
Posts: 372
cityofangels is on a distinguished road
Default Having Trouble With Modal View Presentation

I have a UINavigationController that is being presented modally. There are then 4 VCs that are pushed to before the modal view is being dismissed.

The problem is, after it is dismissed, and I try presenting it again, it presents the last VC instead of the first one. How can I fix this?

VC1:

Code:
- (void)showNewMenu
{
    self.optionsNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self.navigationController presentModalViewController:self.optionsNavController animated:YES];
}
VC2:

Code:
- (void)dismissModalView
{
    [self dismissModalViewControllerAnimated:YES];
}
cityofangels is offline   Reply With Quote
Old 09-11-2011, 10:01 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Either alloc and release in the showNewMenu and ditch the ivar or dismiss all of optionsNavController's modal views before you dismiss optionNavController.
__________________
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-11-2011, 10:11 PM   #3 (permalink)
Beginner iOS Dev
 
Join Date: Feb 2011
Location: Boston
Posts: 372
cityofangels is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Either alloc and release in the showNewMenu and ditch the ivar or dismiss all of optionsNavController's modal views before you dismiss optionNavController.
Hmm how do I alloc and release it? Are you referring to OptionsNavController?

And how would I dismiss all the modal views before dismissing optionsNavController? Just dismiss then as they are being passed to the next VC?
cityofangels is offline   Reply With Quote
Old 09-11-2011, 10:16 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

By alloc and release, I just mean create it in the method, don't leave it in memory as an iVar. You could first call dismiss modal view controller on the parent view controller. Then call dismiss on the parent's parent view controller.
__________________
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-11-2011, 10:20 PM   #5 (permalink)
Beginner iOS Dev
 
Join Date: Feb 2011
Location: Boston
Posts: 372
cityofangels is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
By alloc and release, I just mean create it in the method, don't leave it in memory as an iVar. You could first call dismiss modal view controller on the parent view controller. Then call dismiss on the parent's parent view controller.
I did this, but it loads a blank nav controller.

Code:
- (void)showModalView
{
    UINavigationController *optionsNavController1 = [[UINavigationController alloc]init];
    NewSearch *vc = [[NewSearch alloc]initWithNibName:@"NewSearch" bundle:nil];
    optionsNavController.viewControllers = [NSArray arrayWithObjects: vc, nil];
    optionsNavController1.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:optionsNavController1 animated:YES];
    [optionsNavController1 release];
    [vc release];
}
This modal VC should push to 3 more vc before finally being dismissed.
cityofangels is offline   Reply With Quote
Old 09-11-2011, 10:23 PM   #6 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Alloc the newSearch first and then alloc the nav controller using initWithRootViewController. It's much cleaner that way and I haven't really done it any other way so I don't know if your way works.
__________________
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-11-2011, 10:25 PM   #7 (permalink)
Beginner iOS Dev
 
Join Date: Feb 2011
Location: Boston
Posts: 372
cityofangels is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Alloc the newSearch first and then alloc the nav controller using initWithRootViewController. It's much cleaner that way and I haven't really done it any other way so I don't know if your way works.
Ok so I have this, but it just brings up a blank navcontroller.

Code:
- (void)showModalView
{
    NewSearch *vc = [[NewSearch alloc]initWithNibName:@"NewSearch" bundle:nil];
    UINavigationController *optionsNavController1 = [[UINavigationController alloc]init];
    optionsNavController.viewControllers = [NSArray arrayWithObjects: vc, nil];
    optionsNavController1.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:optionsNavController1 animated:YES];
    [optionsNavController1 release];
    [vc release];
}
cityofangels is offline   Reply With Quote
Old 09-11-2011, 10:28 PM   #8 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Quote:
Alloc the newSearch first and then alloc the nav controller using initWithRootViewController. It's much cleaner that way and I haven't really done it any other way so I don't know if your way works.
Text limit.
__________________
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-11-2011, 10:37 PM   #9 (permalink)
Beginner iOS Dev
 
Join Date: Feb 2011
Location: Boston
Posts: 372
cityofangels is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Text limit.
Ok, cool. That did the trick. Thanks!
cityofangels 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: 407
10 members and 397 guests
7twenty7, apatsufas, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
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:04 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0