iPhone识别按钮被按下 [英] iPhone identify button pressed

查看:72
本文介绍了iPhone识别按钮被按下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有几个按钮的视图,这些按钮都具有相同的目标和动作.

I have a view with several buttons that all have the same target and action.

此刻操作是@selector(doSomething).

At the moment the action is @selector(doSomething).

我需要能够确定按下了哪个按钮,但是我不确定执行此操作的最佳方法.

I need to be able to determine which button is pressed but I'm not sure of the best way to do this.

doSomething方法被声明为...

The method doSomething is declared as...

-(void)doSomething;

-(void)doSomething;

是否有更好的方法来声明此信息,以便获取更多信息?

Is there a better way to declare this so I can get more info out?

感谢您的帮助!

橄榄

推荐答案

如果将方法声明为

- (void)doSomething:(UIButton *)sender

和相应的选择器@selector(doSomething:),然后您可以使用Joshua建议的方法之一检查发件人的身份.

with the corresponding selector @selector(doSomething:), then you can check the identity of the sender using either of the methods Joshua suggested.

这篇关于iPhone识别按钮被按下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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