UITabBar+UITableviewController in navigation based

2020-04-30 01:43发布

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,

2条回答
等我变得足够好
2楼-- · 2020-04-30 02:37

alt text 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.

查看更多
家丑人穷心不美
3楼-- · 2020-04-30 02:37

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.

查看更多
登录 后发表回答