views:

901

answers:

2

Hello!

I used a TabBar in my iPhone application and integrated it programatically. I have several TabBarItems in it and every click will load a XYZ-ViewController with a corresponding XYZ-View.xib.

Now I use to have a screen with the TabBar and a NavBar with SearchBar and a segmented control like in this example of Apple: http://developer.apple.com/iphone/library/samplecode/TableSearch/index.html

But in this example, there is not a TabBar and copy the source into my project causes the problem, that I did the loading in XViewController.m viewDidLoad method:

// Add create and configure the navigation controller.
MyAppDelegate *myAppDelegate = [[UIApplication sharedApplication] delegate];

// Add create and configure the navigation controller.
UINavigationController * navigationController = [[UINavigationControlleralloc] initWithRootViewController:self];
myAppDelegate.navController = navigationController;
[navigationController release];
[myAppDelegate.window addSubview:myAppDelegate.navController.view];

The effect is, that there is a toolbar with the correct title, but there is no searchbar and no TabBar at the bottom.

Could anyone give me a hint what's wrong here?

Thanks a lot, Best Regards.

A: 

I solved the problem:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:test2ViewController];

NSArray* controllers = [NSArray arrayWithObjects:test1ViewController, navigationController, test3ViewController, nil];
[self.myTabBarController setViewControllers:controllers];

Thanks & Best Regards.

Tim
A: 

Thanks for posting this solution...

Regards, Sree

Sree
No problem, I hope it helped you.
Tim