我可以使用 UITabBarController 作为简单的 viewController 切换器吗?

发布于 2024-09-28 20:46:22 字数 703 浏览 3 评论 0原文

我正在创建一个基于 UINavigationController (隐藏栏)的 iPad 应用程序,以便我可以推送和弹出其他 viewControllers 以在应用程序周围导航。但是,我现在想要添加一个部分,其中有两个我希望能够在它们之间切换的视图控制器,因此换句话说,它们是并排的,而不是分层的。

为此可以使用 UITabBarController 吗?我知道在 iPhone 上建议仅在应用程序的根级别使用它们,但由于这是一个 iPad 应用程序,我想知道我是否可以使用它?另外,我想我需要创建一个空的 viewController,在其中创建一个 UITabBarController 并将委托设置给它,然后将两个 viewController 添加到其中......所以实际上我将在其中有一个 viewController另一个 viewController,当我过去这样做时,结果非常不稳定。

我可以这样做吗?我能想到的唯一其他方法是在 UIViewController 中包含两个计划 UIView,但这也意味着我不应该在其中放入任何业务逻辑(糟糕的 MVC!),并且无法做到这一点将是一个痛苦的**。

有什么想法吗?

谢谢!

:-Joe

编辑:我还需要能够在 TabBarController 内的两个 VC 之间滑动动画,并且顶部有一个不动画的菜单栏...我可以这样做吗?

I'm creating an iPad app based on a UINavigationController (with the bar hidden) so I can push and pop other viewControllers for navigation around the app. However, I am now wanting to add a section in which there are two viewControllers that I want to be able to switch between, so in other words they are side-by-side, rather than hierarchical.

Is it okay to use a UITabBarController for this? I am aware that on the iPhone it is recommended they are used only at the root level of the app, but since this is an iPad app I wondered if I could use it? Also, I guess I need to create an empty viewController, create a UITabBarController within it and set the delegate to it, then add the two viewControllers to it... So in effect I will have a viewController within another viewController, and when I have done that in the past the results have been very flaky.

Can I do it this way? The only other way I can think of doing it is to have two plan UIViews within a UIViewController, but that also means I shouldn't really put any business logic in them (bad MVC!), and not being able to will be a right pain in the a**.

Any ideas?

Thanks!

:-Joe

EDIT: I also need to be able to swipe-animate between the two VCs within the TabBarController, AND have a menubar over the top which doesn't animate... Can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

提赋 2024-10-05 20:46:22

当然。

我在我正在开发的应用程序中到处都在做这种事情。我实际上有几种不同类型的“工具栏”,可以选择在不同时间显示。

我所做的是在我的工具栏类中创建一个“父”成员 - 当按下按钮时,我让工具栏调用父类中的方法来执行需要完成的任何操作 - (即显示另一个视图)。

这避免了在另一个视图中创建视图(或在另一个视图控制器中创建视图控制器 - 或其他什么)的混乱 - 工具栏可以点击按钮,但是所有视图都是由根视图/控制器打开的。

希望这有帮助/有意义!

Sure.

I do this kind of thing all over the place in an app I'm working on. I actually have several different types of "toolbars" that can be optionally shown at different times.

What I do is create a "parent" member in my toolbar's class - and when a button is pressed, I have the toolbar call a method in the parent class to do whatever needs to be done - (i.e. display another view).

This avoids the whole mess of creating a view inside another view (or viewcontroller inside another viewcontroller - or whatever) - the toolbar can take the button hits, but all the views are opened by the root view/controller.

Hope this helps/makes sense!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文