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


基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01