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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-05-2009, 02:10 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 11
Default Access self.navigationController in a pushed ViewController

Hello,

I've got a problem, which I can't figure out with the docs.

I got a class, named CustomViewController, which subclasses UIViewController.

In AppDelegate I got a property customNavController, which is connected to a TabBarController from MainWindow.xib. I created an object from class CustomViewController (which comes from CustomViewController.xib) and push it on the customNavController. It appears and works fine, but I need to send the navigationController property inside the CustomViewController object to an instance object. The problem is, inside the the method initWithNibName:bundle: of the CustomViewController, the navigationController property is nil. Also in viewDidLoad: (which is called before initWithNibName:bundle:, which I also don't understand) it is not valid (0x0). Can someone explain me this?

Code in AppDelegate:

Code:
CustomViewController *customViewController = [[[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil] autorelease];

[customNavController initWithRootViewController:customViewController];
Please help, I have done a lot of recherche work already with no result.

Thanks in advance.

kind regards, Phil
coding is offline   Reply With Quote
Old 03-05-2009, 12:02 PM   #2 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,122
Default

It makes perfect sense that your custom view controller has no reference to the nav controller in 'initWithNibName'. That's the first line of code you posted and at that point the view controller has not been associated with the nav controller at all.

'viewDidLoad' will get called as part of 'initWithNibName' to indicate that the view was actually loaded. But your still at that first line of code at this point.

At this point you associate the view controller with the nav controller. The view controller will now have its 'navigationController' property set. The view controller's 'viewWillAppear' and 'viewDidAppear' will be called at this time as it is being displayed.
RickMaddy is offline   Reply With Quote
Old 03-06-2009, 01:35 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 11
Default

Right, I got it. Simple thing if I think about it now.

Big thanks for your help.
coding is offline   Reply With Quote
Reply

Bookmarks

Tags
navigationcontroller, property, self.navigationcontroller, uinavigationcontroller, uiviewcontroller

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: 268
18 members and 250 guests
14DEV, ADY, ArtieFufkin10, Dani77, HemiMG, IphoneSdk, jakerocheleau, JasonR, jimbo, MACralik, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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