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 02-09-2010, 01:57 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
itakenocrud is on a distinguished road
Question Adding a UINavigationBarController to a UITabBarController?

I currently have a UITabBar switching between two different views. I want to add a UINavigationBarController to one of the views such that I can programmatically control the title of it.

I have been looking around and I can't seem to figure out how to do this. Could someone point me to a tutorial/source code?

This is what I attempted to do:

AppDelegate.h
Code:
@interface AppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    UITabBarController *rootController;
	UINavigationController * rootNavBar;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *rootNavBar;
@property (nonatomic, retain) IBOutlet UITabBarController *rootController;

@end
AppDelegate.m
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
	UINavigationController *navBar = [[UINavigationController alloc] initWithRootViewController:rootController];
	[self setRootNavBar:navBar];
    // Override point for customization after app launch    
    [window addSubview:rootController.view];
    [window makeKeyAndVisible];
}
It compiles, but it doesn't add a Nav controller to any of the subviews. What am I missing here?
itakenocrud is offline   Reply With Quote
Old 02-09-2010, 05:09 PM   #2 (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

The nav controller property is not necessary.

Open your MainWindow.xib. Open up the tab controller's view so you can see the tab bar across the bottom. Drag a nav controller directly to the tab bar. After that is in place, go to the list of objects, open the triangles until you find the root controller inside the nav controller. Change the class to be whatever you want to appear first.

In any view controllers that need to change the bar's title, do this:

Code:
[[self navigationItem] setTitle:....];
__________________
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 02-14-2010, 12:35 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
itakenocrud is on a distinguished road
Default Thanks!

Quote:
Originally Posted by BrianSlick View Post
The nav controller property is not necessary.

Open your MainWindow.xib. Open up the tab controller's view so you can see the tab bar across the bottom. Drag a nav controller directly to the tab bar. After that is in place, go to the list of objects, open the triangles until you find the root controller inside the nav controller. Change the class to be whatever you want to appear first.

In any view controllers that need to change the bar's title, do this:

Code:
[[self navigationItem] setTitle:....];
Thanks man that was great. When I did what you said, I was said "oh s**t, that was really simple."
itakenocrud is offline   Reply With Quote
Reply

Bookmarks

Tags
uinavigationbarcontroller, uitabbar

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: 317
6 members and 311 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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