Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hey everyone, I am new to iPhone development and I'm not understanding the whole UINavigationController and UITabBarController idea. Is one a substitute for the other - how do apps such as Tweetie combine both?

I'd like to have my app have a persistent Tab Bar @ the bottom (which seems to be working), but also a Navigation bar at the top which can push/pop views onto the screen without removing the tab bar.

  • How can I accomplish this?
  • What should the hierarchy look like in IB as far as my MainWindow.xib with regards to all of these controllers?
  • What is best practice here?

Thanks very much,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
337 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just wrap the view controller inside the UINavigationController and Place the UINavigationController inside the UITabBar. This will work fine for you…

Example:

NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:2];

tabBarController = [[UITabBarController alloc] init];
[tabBarController setDelegate:self];

UINavigationController *navigationController = nil;
navigationController = [[UINavigationController alloc] initWithRootViewController:<Your View controller1>];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
navigationController = nil;

navigationController = [[UINavigationController alloc] initWithRootViewController:<Your View controller2>];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
navigationController = nil;

tabBarController = tabBarViewControllers;
[tabBarViewControllers release];
tabBarViewControllers = nil;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...