UITabBar functionality without UITabBarController

a 夏天 提交于 2019-12-29 08:22:06

问题


I have this problem, I've got a navigation-based application, and on the one of the detail view i need to have UITabBar, which will display some UITableViews. Since apple documentation says "you should never add a tab bar controller to a navigation controller" it make quite a problem, i've found this sample: link text, it's working, but after picking one of the table view, the UITabBar disappears.


回答1:


Now that you are not using a TabBarController for showing the tableviews (as mentioned in the link), have you made sure that the table views or any other views you are adding when a tab is tapped are correct size?

You are adding a subview or bringing it to top so the table view is probably covering your tab bar.




回答2:


don't use a tab bar controller, just use a UITabBar inside your controller view and manage the switches between UITableViews yourself, either by:

  • loading up as many table views as you need and stacking them (bringing the one corresponding to the tab bar hit to front)
  • switching a single table view's data source and delegate among a few helper objects - one per tab in your bar. When the user clicks a tab, reset the single table view's data source then instruct it to reloadData



回答3:


When they are choosing an item from your table view are you pushing a new view controller onto your navigation controller? If so, you will leave the tab bar behind!

Without some hefty hacking, you generally can't do what you're trying to do. What you'd have to do instead is to deal with adding new views yourself when a table cell is selected so the new views you add don't overlap the tab bar at the bottom. Though this will probably break the navigation controller.

Though my advice is to rethink that part of the app's ui so you don't care that the tab bar vanishes. Sorry :(



来源:https://stackoverflow.com/questions/3308458/uitabbar-functionality-without-uitabbarcontroller

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