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 应用程序操作按钮


- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- URL编码Swift iOS 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- UITextView 内容插图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01