开发者

UITabBar Controller and UITableView Controller - would one effect the other?

开发者 https://www.devze.com 2023-03-01 04:52 出处:网络
Perhaps a simple or stupid question. I have tested three separate apps, each simple UITableViewController apps with detail view controllers pushed onto the stack. All work with no problems.

Perhaps a simple or stupid question. I have tested three separate apps, each simple UITableViewController apps with detail view controllers pushed onto the stack. All work with no problems.

I've now decided to build a new app that uses a three tab UITabBar Controller as my rootviewcontroller and have these three separate tableViewControllers running off the tabBar controller. I can fire up my first level TableViews but I can't push their respective childViewControllers onto the stack. I'm using the same class code for each UITableViewController in the tabBar app as I tested in the tableView app.

开发者_Python百科

Am I missing something obvious here? Why wouldn't this work because of a TabBar Controller?

Thanks for any insights in advance.


If you look closer at your three separate apps, you'll see they have the UITableViewControllers inside of UINavigationControllers. You probably left the navigation controllers out of your version with the UITabBarController.

The hierarchy should look something like this:

UITabBarController
 ┣ UINavigationController
 ┃  ┗ UITableViewController
 ┣ UINavigationController
 ┃  ┗ UITableViewController
 ┗ UINavigationController
    ┗ UITableViewController


Do this: create a new project based on the tab bar controller template, expand the tab and you'll see some UIViewControllers hanging there. Now drag a "Navigation Controller" from the library and drop it under the tabs, you'll see it has a UIViewController as a child. Drop a "Table View Controller" on that child.

You'll see the structure proposed by Anomie (who is a fast typer :P ). This is a very typical structure for an iPhone app.

0

精彩评论

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