iPhone 应用程序操作按钮 [英] iPhone app Action Button

查看:19
本文介绍了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 应用程序操作按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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