UITabBar+UITableviewController in navigation based applications

牧云@^-^@ 提交于 2019-12-20 05:17:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!