问题
I am trying to put a UITabBar on a Rootviewcontroller.xib to a Navigation based Application. I know that we used navigation based applicaitons for Tableviews and by default those .xib consists of a tableview. I tried to put a UITabBar in the bottom of rootview but it is not setting over there.
I saw that if we used viewbased application or a window based application we can arrange both UITabBar and UITableView on the same view. What I want to know here is:
1) Can we place a UITabBar in Navigation based applications if so how?
2) If we shift from root views to other detailed views i want the UITabBar to be appeared on all the other views can any one tell me how can i do this.
Thanks,
回答1:
This is how your Xib should look. Tab Bar controller is parent Controller.. Navigation controller shown in the image i.e. "First" will be just for the first Tab .. if you need the Navigation controller for the "Second" tab, you have to add one more Navigation controller.
Adding Tabbar controller with navigation controller in the order shown in the image.
回答2:
If I am reading your correctly, I think that you're thinking of it in the wrong way.
From what I'm reading you're trying to have:
UINavigationController -> "Tab Bar Controller (as the root to the stack)" -> UITableViewController (as the Tab Bar Controller's selected view)
Then, whenever a user selects a cell in the table you push a new view view into the UINavigationController while keeping the tab bar shown.
If this is right, then the solution is to rework your view controllers.
What you want is a UITabBarController -> UINavigationController (as the view for the selected UITabBarItem) which holds a UITableViewController (or UIViewController with a UITableView) for your main view.
This way whenever you select an item within the table, you push it into the parent UINavigationController stack, and the UITabBar at the bottom will remain.
If you need an example, I'd be glad to try and help, too.
来源:https://stackoverflow.com/questions/3761716/uitabbaruitableviewcontroller-in-navigation-based-applications