iPhone app Action Button(iPhone 应用程序操作按钮)
问题描述
我需要在我的 iPhone 应用程序中添加一个操作按钮.单击该按钮时,需要弹出带有按钮的 UIActionSheet.谁能告诉我如何添加操作按钮?- 表示 iPhone 应用程序是否有内置操作按钮?还是我们需要创建一个带有图像的新按钮?
I need to add an action button in my iPhone application. When that one is clicked the UIActionSheet with buttons need to be popped up. Can any one tell me how to add an action button? - means is there any in built action button for iPhone app? or do we need to create a new button with image?
提前致谢!
推荐答案
假设这是在视图控制器中,您可以执行以下操作:
Assuming this is in a view controller, you can do something like:
- (void)viewDidLoad
{
UIBarButtonItem *actionButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:self
action:@selector(methodThatShowsSheet)];
self.navigationItem.rightBarButtonItem = actionButton;
[actionButton release];
}
(请原谅奇怪的缩进,使其适合合理的宽度(我通常只是让 Xcode 自动包装所有内容).
(Pardon the weird indentation to make it fit in a reasonable width (I normally just let Xcode wrap-indent everything automatically)).
有关如何实现 methodThatShowsSheet
,请参阅 Nick Veys 的回答.
See Nick Veys' answer for how to implement methodThatShowsSheet
.
这篇关于iPhone 应用程序操作按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone 应用程序操作按钮


基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01