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 11-23-2009, 07:56 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 4
Default Tab Bar Controller & Navigation Controller - View pushed not displayed

Hi all,

I have a problem to push a view in a Navigation Controller embedded in a Tab Bar Controller. Here is the structure of the app:

- App hosts the Tab Bar and a Delegate
- One of the view controllers stacked in the Tab Bar is a Navigation Controller
- This Nav Controller hosts the Nav Bar and delegate to File's owner > FirstViewController class & FirstView.xib
- This xib contains a tableview. On an item click, I would like to push a new view to the Nav Controller > FirstViewDetailsController & FirstViewDetails.xib
- FirstViewDetails is a simple UIview.

>> The code in the click event method in FirstViewController:
NSString *nibName = @"FirstViewDetails";
UIViewController *targetViewController = [[FirstViewDetailsController alloc] initWithNibName:nibName bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:targetViewController animated:YES];

>> The code in nibNameOrNil method in FirstViewDetailsController:
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
NSLog(@"First View Details initNIB %@", nibNameOrNil);
// Custom initialization
}

RESULT:
- First View Details initNIB FirstViewDetails is displayed in log window => event is fired correctly and FirstViewDetails seems to be constructed correctly
- The UIView FirstViewDetails is not stacked nor displayed

Thanks for your help.
cphilc is offline   Reply With Quote
Old 11-23-2009, 09:21 AM   #2 (permalink)
Registered Member
 
Jagged's Avatar
 
Join Date: May 2009
Age: 30
Posts: 48
Default

did you add your navcontroller to the subviews of the parentview?


Code:
[window addSubview:navigationController.view];
__________________
iPhoneDist.com - distribution service for iPhone applications

New App: Time Prophet
Jagged is offline   Reply With Quote
Old 11-23-2009, 10:46 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 4
Default

Quote:
Originally Posted by Jagged View Post
did you add your navcontroller to the subviews of the parentview?

Code:
[window addSubview:navigationController.view];
The FirstView (navigationcontroller) is well displayed when I click on the tab bar item.
=> the navigationcontroller view is well attached (to me) ???

The issue is when I click on an table item in FirstView in order to display the FirstViewDetail (regular UIView).
The FirstViewDetail viewDidLoad is never called

I can't understand because I don't [window addSubview:navigationController.view] anywhere.
Where I'm supposed to add it?

Phil

Last edited by cphilc; 11-23-2009 at 10:50 AM.
cphilc is offline   Reply With Quote
Old 11-23-2009, 10:52 AM   #4 (permalink)
Registered Member
 
Jagged's Avatar
 
Join Date: May 2009
Age: 30
Posts: 48
Default

in


- (void)applicationDidFinishLaunchingUIApplication *)application
{
...
...
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
...
...
}


this is in the <AppName>AppDelegate.m
__________________
iPhoneDist.com - distribution service for iPhone applications

New App: Time Prophet
Jagged is offline   Reply With Quote
Old 11-23-2009, 11:41 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 4
Default

Quote:
Originally Posted by Jagged View Post
in


- (void)applicationDidFinishLaunchingUIApplication *)application
{
...
...
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
...
...
}


this is in the <AppName>AppDelegate.m
The navigation controller is not created at app launching but when the user clicks on a specific tab. AppDelegate manages only the tab bar.

On the other hand, FirstView manages the navigation bar.

I can't understand, please help ...
cphilc is offline   Reply With Quote
Old 11-23-2009, 04:54 PM   #6 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
Default

You almost certainly don't have a self.navigationController property. In your code, add the line as shown below:

Code:
NSString *nibName = @"FirstViewDetails";
UIViewController *targetViewController = [[FirstViewDetailsController alloc] initWithNibName:nibName bundle:[NSBundle mainBundle]];

// add this here:
NSLog(@"my nav controller is: %@", self.navigationController);
[self.navigationController pushViewController:targetViewController animated:YES];
Run it. I bet it will print null. You need to instantiate the nav controller somewhere. Are you doing everything in code or using nib files?
jsd is offline   Reply With Quote
Old 11-23-2009, 06:26 PM   #7 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 4
Default

Quote:
Originally Posted by jsd View Post
You almost certainly don't have a self.navigationController property. In your code, add the line as shown below:

Code:
NSString *nibName = @"FirstViewDetails";
UIViewController *targetViewController = [[FirstViewDetailsController alloc] initWithNibName:nibName bundle:[NSBundle mainBundle]];

// add this here:
NSLog(@"my nav controller is: %@", self.navigationController);
[self.navigationController pushViewController:targetViewController animated:YES];
Run it. I bet it will print null. You need to instantiate the nav controller somewhere. Are you doing everything in code or using nib files?
In finally found the issue and fixed it.
In fact, I centralized tabbar & navigation controllers in AppDelegate.
Because I did make a link betweed the NavigationController of FirstView and this AppDelegate, it didn't work.

I'd like to thank you for your time and help.

Next time, I will do more things by code, NIB files and Interface Builder are a little bit tricky ... even, when you are used, it's quite powerful.

Phil
cphilc is offline   Reply With Quote
Old 01-02-2010, 08:27 PM   #8 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 1
Default Same problem

Quote:
Originally Posted by cphilc View Post
In finally found the issue and fixed it.
In fact, I centralized tabbar & navigation controllers in AppDelegate.
Because I did make a link betweed the NavigationController of FirstView and this AppDelegate, it didn't work.

I'd like to thank you for your time and help.

Next time, I will do more things by code, NIB files and Interface Builder are a little bit tricky ... even, when you are used, it's quite powerful.

Phil
Hi Phil-
I am new to iPhone development too. I am having the same problem which you described above. Can you please let me know how you fixed it?

Thanks for your help in advance.

Regards-
Siri
abiz is offline   Reply With Quote
Reply

Bookmarks

Tags
controller, navigation, tab bar

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: 275
23 members and 252 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, fkmtc, HDshot, HemiMG, iDifferent, jakerocheleau, JasonR, jimbo, macquitzon216, mer10, prchn4christ, Rudy, sacha1996, silverwiz, sneaky, spiderguy84, Sunny46, theone8one
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 03:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0