简体   繁体   English

有没有一种简单的方法在iPhone上创建模态按钮菜单?

[英]Is there a simple way to create a modal button menu on the iPhone?

Plenty of applications seem to do this. 很多应用程序似乎都这样做。 For example, go to Apple's mail application and press the "reply" button on the toolbar. 例如,转到Apple的邮件应用程序,然后按工具栏上的“回复”按钮。 You'll get a menu with buttons that say "Reply", "Reply All", "Forward" and "Cancel" that will scroll up from the bottom. 您将获得一个菜单,其中的按钮会显示“回复”,“全部回复”,“转发”和“取消”,这些按钮将从底部向上滚动。

The way I figure I could do this is to create a short view in IB with the buttons I want, present it modally, and right a view controller to handle the buttons. 我想这样做的方法是在IB中使用我想要的按钮创建一个短视图,以模态方式呈现它,并且右视图控制器来处理按钮。

It seems like this is so common that there must be an easier way to do it (like how easy it is to add to the toolbar and navigation bar). 看起来这很常见,必须有一种更简单的方法(比如添加到工具栏和导航栏是多么容易)。

Is there some widget or shortcut that I am missing? 我缺少一些小部件或快捷方式吗?

This is actually just a UIActionSheet. 这实际上只是一个UIActionSheet。 You can create one pretty easily. 你可以很容易地创建一个。

http://ykyuen.wordpress.com/2010/04/14/iphone-uiactionsheet-example/ http://ykyuen.wordpress.com/2010/04/14/iphone-uiactionsheet-example/

只需在IB中创建一个具有所需控件的视图控制器,然后在当前视图控制器上调用[self presentModalViewController:[[[MyModalViewController alloc] init] autorelease] animated:YES]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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