View Full Version : Adding a Tab Bar Object

Dec 15, 2008, 01:08 AM
I was looking at adding a tab bar object to TheElements sample code, but was wondering how to do it. I am trying to make a tab bar object called "First", so I made some .h and .m files called "FirstTabController". A added the header file to TheElementsAppDelegate, and I declared it in TheElementsAppDelegate.m the following way:

localNavigationController = [self createNavigationControllerWrappingViewControllerForDataSourceOfClass:[FirstTabController class]];
[localViewControllersArray addObject:localNavigationController];

[localNavigationController release];

Firstly, is this implementation all right?

In FirstTabController, I put the following code:

#import "FirstTabController.h"
#import "TheElementsAppDelegate.h"

@implementation FirstTabController;

- (NSString *)name {
return @"First";

- (NSString *)navigationBarName {
return @"First";

- (BOOL)showDisclosureIcon
return NO;
- (UIImage *)tabBarImage {
return [UIImage imageNamed:@"first.png"];

What else do I have to do in order to get my tab to display and just display a blank view?

Thanks in advance!

Dec 15, 2008, 04:57 PM
OK, I have established that I need the following code in TheElementsAppDelegate.m if I want to show an empty view:

UIViewController * viewController = nil;
viewController = [[UIViewController alloc] init];

UIView * view = nil;
view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

viewController.view = view;
[view release];

UINavigationController * navigationController = nil;
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];

[localViewControllersArray addObject:navigationController];
[navigationController release];

How can I implement this into a view controller subclass?