如何在iPhone中创建物理菜单按钮(如Android中的菜单按钮)? [英] How to create physical menu button (like the one in Android) menu in iPhone?

查看:133
本文介绍了如何在iPhone中创建物理菜单按钮(如Android中的菜单按钮)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iPhone中基于导航的应用程序.

I am developing a navigation based application in iPhone.

我要在其中创建类似于Android手机中的菜单之类的物理菜单按钮.

In which I want to create physical menu button like menu like the one in Android phones.

可以从层次结构中的任何视图访问菜单.

The menu can be accessed from any view in the hierarchy.

任何人都不知道我们如何实现这一目标.

Do any one have any idea how can we achieve this .

我们可以在UINavigationBar中添加类似抽屉的菜单吗?

Can we add a drawer like menu to UINavigationBar ?

请不要建议使用tabbarcontroller,因为它是最后一个选择.

Please don't suggest the tabbarcontroller as it is the last option.

推荐答案

您应该做的是创建UIViewController的子类,例如MasterViewController.具有所有视图控制器子类MasterViewController.在MasterViewController中,您可以编写代码来创建和显示抽屉视图,然后所有视图控制器将继承该代码并可以随时对其进行调用.

What you should do is create a subclass of UIViewController, e.g. MasterViewController. Have all of the view controllers subclass MasterViewController. In the MasterViewController you can write code to create and display your drawer view, and then all of your view controllers will inherit that code and can call it on themselves at any point.

要在以下位置滑动视图:

To slide the view in:

drawerView.frame = CGRectMake(0, -1*drawerView.frame.size.height, self.view.frame.size.width, whateverHeight);
[UIView beginAnimations:nil context:NULL];
drawerView.frame = CGRectMake(0, 0, self.view.frame.size.width, whateverHeight);
[UIView commitAnimations];

drawerView.frame = CGRectMake(0, -1*drawerView.frame.size.height, self.view.frame.size.width, whateverHeight);
[UIView beginAnimations:nil context:NULL];
drawerView.frame = CGRectMake(0, 0, self.view.frame.size.width, whateverHeight);
[UIView commitAnimations];

这篇关于如何在iPhone中创建物理菜单按钮(如Android中的菜单按钮)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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