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 03-24-2009, 02:48 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 11
napoleone1981 is on a distinguished road
Question initWithNibName not firing

Hi all,
I've a UITabBarController with for UIViewController (each of one with its xib) built with Interface Builder.

I'm trying to do something inside the initWithNibName of the first ViewController, but its initWithNibName methode is not firing at all... so I put the code inside the viewDidLoad method.

How to fire the initWithNibName method without directly calling it??

In IB, in the main XIB all the UIViewController have their name set to the class name and the separate nib name set. In the separate nib, all the File's owner are set to the class type of theri respective UIViewController and all the outlets are bound cause the application is running ok...

Any help?
__________________
By,
N@poleone
napoleone1981 is offline   Reply With Quote
Old 03-24-2009, 02:58 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,050
wuf810 is on a distinguished road
Default

Quote:
Originally Posted by napoleone1981 View Post
Hi all,
I've a UITabBarController with for UIViewController (each of one with its xib) built with Interface Builder.

I'm trying to do something inside the initWithNibName of the first ViewController, but its initWithNibName methode is not firing at all... so I put the code inside the viewDidLoad method.

How to fire the initWithNibName method without directly calling it??

In IB, in the main XIB all the UIViewController have their name set to the class name and the separate nib name set. In the separate nib, all the File's owner are set to the class type of theri respective UIViewController and all the outlets are bound cause the application is running ok...

Any help?
What's the problem....just use viewDidLoad as you are doing.

initWithNibName gets calls when you init/alloc the object yourself. Because you've used IB and are probably just pushing the view using the ViewController, viewDidLoad is called instead.
wuf810 is offline   Reply With Quote
Old 03-24-2009, 03:21 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 11
napoleone1981 is on a distinguished road
Default

Quote:
Originally Posted by wuf810 View Post
What's the problem....just use viewDidLoad as you are doing.

initWithNibName gets calls when you init/alloc the object yourself. Because you've used IB and are probably just pushing the view using the ViewController, viewDidLoad is called instead.
Well, I read (in the sample code comments...) that viewDidLoad is called after the view loaded and initWithNibName before the view loads...

Moreover, maybe I'm wrong cause I'm a very newbie, viewDidLoad can be called more than one time if the system dealloc my view while it's not in use and then reinit it... isn't it??

In other words... Where do I have to put my "initialize" code that must be run only once?? (Using a xib file)

Thanks
__________________
By,
N@poleone
napoleone1981 is offline   Reply With Quote
Old 03-24-2009, 03:33 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,050
wuf810 is on a distinguished road
Default

Quote:
Originally Posted by napoleone1981 View Post
Well, I read (in the sample code comments...) that viewDidLoad is called after the view loaded and initWithNibName before the view loads...

Moreover, maybe I'm wrong cause I'm a very newbie, viewDidLoad can be called more than one time if the system dealloc my view while it's not in use and then reinit it... isn't it??

In other words... Where do I have to put my "initialize" code that must be run only once?? (Using a xib file)

Thanks
Once per View or once per app launch? If you are initialising view variables, then viewDidLoad gets called once and you setup here for each time your load a view (basically each time you create an Instance of your view). If you mean for your application, then you initialise just once in your AppDelegate method.
wuf810 is offline   Reply With Quote
Old 03-24-2009, 07:09 AM   #5 (permalink)
Dr. Touch Cocoa Helpdesk
iPhone Dev SDK Supporter
 
Join Date: Sep 2008
Location: Vienna, Austria
Posts: 537
Oliver Drobnik is on a distinguished road
Send a message via AIM to Oliver Drobnik Send a message via MSN to Oliver Drobnik Send a message via Skype™ to Oliver Drobnik
Default

Quote:
Originally Posted by wuf810 View Post
Once per View or once per app launch? If you are initialising view variables, then viewDidLoad gets called once and you setup here for each time your load a view (basically each time you create an Instance of your view). If you mean for your application, then you initialise just once in your AppDelegate method.

You are confusing something. It's not initWithNibName that is called when a XIB file is loaded, but awakeFromNib.

cheers
Oliver


Dr. Touch
Oliver Drobnik is offline   Reply With Quote
Old 03-24-2009, 02:08 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 11
napoleone1981 is on a distinguished road
Default

Quote:
Originally Posted by Oliver Drobnik View Post
You are confusing something. It's not initWithNibName that is called when a XIB file is loaded, but awakeFromNib.

cheers
Oliver


Dr. Touch
Ok, I'll try later this evening... Thanks
__________________
By,
N@poleone
napoleone1981 is offline   Reply With Quote
Old 03-24-2009, 05:48 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 11
napoleone1981 is on a distinguished road
Smile

Quote:
Originally Posted by Oliver Drobnik View Post
You are confusing something. It's not initWithNibName that is called when a XIB file is loaded, but awakeFromNib.

cheers
Oliver


Dr. Touch
Ok, I tried and you're right... Thanks!
__________________
By,
N@poleone
napoleone1981 is offline   Reply With Quote
Old 02-22-2010, 10:10 PM   #8 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

I'm having a similiar problem, all I want to do is set self.title for it to appear in my navigation controller but my initWithNibName isn't being called, can I just set the title somewhere else, because it's not working if I do it in the viewDidLoad?

Thanks!
doanelinde is offline   Reply With Quote
Old 02-23-2010, 12:25 AM   #9 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

I've set the title for the navigation controller in both initWithNibName and viewDidLoad, and they both worked fine.
JasonR is offline   Reply With Quote
Old 02-23-2010, 10:08 AM   #10 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

Well normally I'd set it in initWithNibName and that'd work fine but for some reason that's not being called now...

And it doesn't seem to be working when I set it in viewDidLoad, or anywhere else..
doanelinde is offline   Reply With Quote
Old 02-23-2010, 11:58 AM   #11 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

You are going to have to post some code, or at least tell us what you are doing so we can figure out if you are making a mistake. Because both methods work just fine normally.
JasonR is offline   Reply With Quote
Old 02-23-2010, 03:15 PM   #12 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

I am embedding a navigation view inside a tab bar view. I connected it up using IB, according to this tutorial:

Twillo: How to embed a navigation controller inside a tab bar controller

I've checked with NSLogs and my initWithNibName definitely isn't firing and viewDidLoad definitely is. All I should need in my viewDidLoad is still "self.title=@"Something";" isn't it?

My view is loading fine inside the navView, which is connected correctly the controller, yet doesn't seem to be accessing the navigationView.

Any ideas? Or is there anything else I can tell you about it?

Thanks!
doanelinde is offline   Reply With Quote
Reply

Bookmarks

Tags
initwithnibname, uitabbarcontroller

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: 333
3 members and 330 guests
guusleijsten, Kryckter, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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