开发者

TabBar combined with Navigation Bar / Search Bar and TableView

I used a TabBar in my iPhone application and integrated it programmatically. 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.
U开发者_如何转开发INavigationController * 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?


I solved the problem:

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜