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-29-2011, 05:58 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 245
samurle is on a distinguished road
Question How to exit UINavigationController?

If I created a UINavigationController programmatically, how would I exit it?
Exit, as in deallocate it from memory.

For example, let's say my app starts off with a full-screen main menu with some buttons,
and then when I click on a button, I create a navigation controller with its own view.

How would I then exit the navigation controller, and go back to the main menu?

Last edited by samurle; 09-29-2011 at 07:17 AM.
samurle is offline   Reply With Quote
Old 09-29-2011, 07:11 AM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

It's not clear what you mean. The tile mentions navigation controller but then you talk about navigation bar. Those aren't the same. How you dispose of it depends on how you create and present it. What you allocate you must release, if you present a modal view controller you need to dismiss it. If you add it as a subview you need to remove it from its superview... etc.
baja_yu is offline   Reply With Quote
Old 09-29-2011, 07:20 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 245
samurle is on a distinguished road
Question

Quote:
Originally Posted by baja_yu View Post
It's not clear what you mean. The tile mentions navigation controller but then you talk about navigation bar. Those aren't the same. How you dispose of it depends on how you create and present it. What you allocate you must release, if you present a modal view controller you need to dismiss it. If you add it as a subview you need to remove it from its superview... etc.
I corrected it.

This is a navigation controller.

It's not a modal view controller, there's nothing to dismiss.
It's not a view, there's nothing to remove from a superview.

How to exit it?
samurle is offline   Reply With Quote
Old 09-29-2011, 07:23 AM   #4 (permalink)
iPhone developer
 
Join Date: Sep 2011
Location: Srikakulam
Posts: 2
sr.ramarao2009590 is on a distinguished road
Default

self.navigationController.hidden=YES;
sr.ramarao2009590 is offline   Reply With Quote
Old 09-29-2011, 07:51 AM   #5 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 245
samurle is on a distinguished road
Arrow

Quote:
Originally Posted by sr.ramarao2009590 View Post
self.navigationController.hidden=YES;
Please read my post again.

How to exit through memory deallocation, as I stated in my question.
samurle is offline   Reply With Quote
Old 09-29-2011, 07:54 AM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

How are you putting it onto the screen in the first place?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 09-29-2011, 08:12 AM   #7 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 245
samurle is on a distinguished road
Question

Quote:
Originally Posted by BrianSlick View Post
How are you putting it onto the screen in the first place?
I allocate it programmatically:
Code:
RooViewController *rootViewController = [[RooViewController alloc] init;
[self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[self.window makeKeyAndVisible];
How to exit the navigation controller from inside it's root view?
samurle is offline   Reply With Quote
Old 09-29-2011, 08:16 AM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

1. You're leaking it. See the properties link in my signature for guidance.
2. Assuming you are replacing the root controller like this:
Code:
self.window.rootViewController = anotherViewController;
...then that's all you need to do (other than properly releasing both the RooViewController and navigation controller)
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 09-29-2011, 08:39 AM   #9 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 245
samurle is on a distinguished road
Question

Quote:
Originally Posted by BrianSlick View Post
1. You're leaking it. See the properties link in my signature for guidance.
2. Assuming you are replacing the root controller like this:
Code:
self.window.rootViewController = anotherViewController;
...then that's all you need to do (other than properly releasing both the RooViewController and navigation controller)

Thanks for the help!

If I set self.window.rootViewController to nil or to another controller, should my root view's
viewDidUnload method get called? Because I added a NSlog in that method, and it doesn't get called.

I'm just trying to find some indication that the rootViewController has been deallocated.
samurle is offline   Reply With Quote
Old 09-29-2011, 11:09 AM   #10 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

viewDidUnload is not part of the teardown routine, so no. Put a log in dealloc. Or use Instruments.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 09-29-2011, 06:04 PM   #11 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 245
samurle is on a distinguished road
Arrow

Quote:
Originally Posted by BrianSlick View Post
viewDidUnload is not part of the teardown routine, so no. Put a log in dealloc. Or use Instruments.
I added these lines, but I think they're overkill and not needed. Since I'm already at the rootView when all of this happens.
viewDidUnload still doesn't get called, but viewDidDisappear does get called.

Quote:
[self.navigationController popToRootViewControllerAnimated:TRUE];
[self.navigationController dismissModalViewControllerAnimated:TRUE];

[self.view removeFromSuperView];
[self.window.rootViewController.view removeFromSuperView];

self.view = nil;
self.window.rootViewController.view = nil;

// Last line
self.window.rootViewController = nil;
I think the last line is all I need.

And exiting this way does create one small problem. The exit happens very fast. Too fast. It's not animated.
So, the exit either needs to be animated, or some kind of transition needs to happen.

Last edited by samurle; 09-29-2011 at 07:05 PM.
samurle is offline   Reply With Quote
Old 09-29-2011, 06:44 PM   #12 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You're going to have to do something manual to animate that.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
navigation bar, uinavigationcontroller

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: 385
16 members and 369 guests
13dario13, 7twenty7, eski, EvilElf, glenn_sayers, HemiMG, iOS.Lover, jarv, LunarMoon, 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,122
Posts: 402,906
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:20 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0