简体   繁体   中英

Custom Tab Bar Controller with Navigation Bar

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:

例子gif

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM