Custom Tab Bar Controller with Navigation Bar

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 07:35:07

问题


I've spent a while looking for a solution to this but haven't found one. I'd like to create a Tab Bar Controller with a navigation bar which is present in all child views. From what i gather, the hierarchy does not allow this, as a tab bar is (equal?) or higher in the hierarchy than a Navigation Controller, and therefor the only simple implementation is to embed each child view of the Tab Bar Controller in a Navigation Controller, like this:

I was wondering if there is any technical reason why it wouldn't be possible to program a custom Tab Bar Controller that features a Navigation Bar. I'm not asking someone to implement this for me, but as I haven't found any library/existing example of it, I'd like to know if there's any technical reason why this isn't possible, before I go down the path of trying to implement it.

Thanks for the help


回答1:


Even if I have not met solutions like yours, and also as I was always aware of such solutions, I would try to implement and sent to beta app review.

Docs say you shouldn't do that, and Apple doesn't want you to do this and it can and will cause problems. But if you don't mind you make a little hack : Just don't use TabBarController.

  1. Put a TabBar to your view,
  2. make the view controller for this view a tabBar delegate
  3. respond to user event on this tabBar in the code of this view controller.

I created a solution (few years ago), that was made of TabBarController, being a parent view controller of a master-detail view controller. As it was a bit hard to establish, I used a library name ISMViewController.

It seemed to be a little hack, but it was approved in the App review. I sent a project to the app review, right after establishing those simple scenes, with some empty buttons and labels, just to check if they are fine with it. They were. So then I started to develop on this controller scheme and it's still in the App Store.

If something is obviously not supported to do in storyboard, it is likely not to be a common solution, or not good way. But I don't think it is absolutely forbidden. For example tab bar controller as well as master detail view controller for iPad should be root view controller for some reasons.

Apple conventions followed by reviewing apps in the App Review could comply with these solutions, but I would definitely try.



来源:https://stackoverflow.com/questions/39417907/custom-tab-bar-controller-with-navigation-bar

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