iOS 自定义菜单(导航控制器?)

发布于 2024-12-04 12:00:09 字数 267 浏览 0 评论 0原文

我计划了一个应用程序,需要在整个应用程序中拥有一个自定义菜单。它不是工具栏或类似的东西,所以我认为常规的 UINavigationController 或 UITabBarController 无法完成这项工作。

创建出现在所有视图中的自定义菜单的最佳方法是什么?我想过只使用自定义菜单创建一个视图并为每个视图分配它,但这似乎有点过分了。扩展 UINavigationController 也可能是一种选择,但我不确定。

很想听听您的意见。

谢谢你! :)
谢伊。

I have an app planned out that needs to have a custom menu throughout the application. Its not a toolbar or anything like that so i don't think a regular UINavigationController or a UITabBarController will do the job.

What would be the best approach to creating this custom menu that appears in all views? I thought of just creating a view with the custom menu and alloc it for each view but it seems like a bit of an overkill. Extending UINavigationController might also be an option, but I'm not sure.

Would love to hear your opinions.

Thank you! :)
Shai.

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

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

发布评论

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

评论(5

咆哮 2024-12-11 12:00:09

UINavigationController 和 UITabBarController 几乎总是最好的方法,因为它们内置了视图和内存管理。您可以执行以下操作:

  1. 创建隐藏选项卡栏的 UITabBarController 子类。请参阅本页的最后一篇文章: http:// /www.iphonedevsdk.com/forum/iphone-sdk-development/4091-uitabbarcontroller-hidden-uitabbar.html 使此 UITabBarController 可在一个单例对象。
  2. 为您的菜单创建一个视图,并创建一些与菜单按钮对应的 IBAction。
  3. 当按下菜单按钮时,您可以手动切换 uitabbarcontroller 的选项卡,如下所示: tabBarController.selectedIndex = x;

The UINavigationController and the UITabBarController are pretty much always the best way to go because they have view and memory management built in. Here's what you can do:

  1. Create a subclass of UITabBarController that hides the tab bar. See the last post on this page: http://www.iphonedevsdk.com/forum/iphone-sdk-development/4091-uitabbarcontroller-hidden-uitabbar.html Make this UITabBarController accessible on a singleton object.
  2. Create a view for your menu and some IBActions corresponding to the menu buttons.
  3. When a menu button is pressed, you can manually switch the tabs of the uitabbarcontroller as follows: tabBarController.selectedIndex = x;
自在安然 2024-12-11 12:00:09

我同意阿德的观点。我认为添加到共享类的弹出窗口控制器最适合 iOS 风格(我将其放在 AppDelegate 中,以便从任何地方引用它,并避免创建多个实例并仅使用一个您将继续显示的实例/每当您想查看菜单时就隐藏)

I agree with ade. I think a popover controller added to a shared class would fit best to the iOS style (I'd put it in AppDelegate in order to have reference to it from anywhere and to avoid creating multiple instances and using only one which you will keep displaying / hiding whenever you wish to see the menu)

爱,才寂寞 2024-12-11 12:00:09

我可以想到两个选择: 1.子类UINavigationController,隐藏标准UINavigationBar的视图并创建您自己的视图并将其放在它的上面(丑陋,谁知道结果会是什么样子)。 2. 将菜单添加为 UIWindow 的子视图,以便它位于整个应用程序中所有内容的顶部。

I can think of two options: 1. Subclass UINavigationController, hide the standard UINavigationBar's view and create your own view and put it on top of it (ugly and who knows what the results will end up like). 2. Add the menu as a subview of UIWindow so it stays on top of everything throughout the app.

魂归处 2024-12-11 12:00:09

我认为最好的方法是创建一个自定义工具栏并在整个应用程序中使用它。子类化 UINavBar 是另一种选择,但 Apple 不推荐,所以我不会去那里。

I think the best way is to create a custom tool bar and use it across the app. Subclassing UINavBar is another option but not recommended by Apple so I would not go there.

清引 2024-12-11 12:00:09

我会考虑使用弹出窗口样式菜单,例如 WEPopover

I'd look into using a popover style menu such as WEPopover

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