带有导航栏的自定义标签栏控制器 [英] Custom Tab Bar Controller with Navigation Bar

查看:25
本文介绍了带有导航栏的自定义标签栏控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了一段时间寻找解决方案,但没有找到.我想创建一个带有导航栏的标签栏控制器,该导航栏存在于所有子视图中.从我收集的信息来看,层次结构不允许这样做,因为标签栏在层次结构中(等于?)或高于导航控制器,因此唯一的简单实现是将标签栏控制器的每个子视图嵌入导航控制器,像这样:

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.

感谢您的帮助

推荐答案

即使我没有遇到过像你这样的解决方案,而且我一直都知道这样的解决方案,我会尝试实施并发送到测试版应用程序审查.

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.

文档说你不应该这样做,Apple 不希望你这样做,它可能并且会导致问题.但是如果你不介意你做一个小技巧:只要不要使用TabBarController.

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. 在你的视图中放置一个 TabBar,
  2. 将此视图的视图控制器设为 tabBar 委托
  3. 在此视图控制器的代码中响应此 tabBar 上的用户事件.

<小时>

我创建了一个解决方案(几年前),它由 TabBarController 组成,它是父项 视图控制器主细节视图控制器.由于建立起来有点困难,我使用了一个库名ISMViewController.


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.

这似乎是一个小技巧,但它在应用审查中获得了批准.在建立那些简单的场景后,我立即将一个项目发送给应用程序审查,其中包含一些空按钮和标签,只是为了检查他们是否可以接受.他们是.然后我开始开发这个控制器方案,它仍然在 App Store 中.

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.

如果故事板显然不支持某些事情,那么它可能不是一个通用的解决方案,或者不是一个好方法.但我不认为这是绝对禁止的.例如,由于某些原因,iPad 的标签栏控制器和主细节视图控制器应该是根视图控制器.

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 在 App Review 中审查应用程序的惯例可能符合这些解决方案,但我肯定会尝试.

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

这篇关于带有导航栏的自定义标签栏控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆