iPhone/目标C:如何从NIB获取UIButton实例 [英] iPhone/Objective C: How can I get the UIButton instance from NIB

查看:34
本文介绍了iPhone/目标C:如何从NIB获取UIButton实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在笔尖上放置了1个UIButton,当用户单击此按钮时,一个IBAction方法使用 Status 参数连接到它.

I placed 1 UIButton on nib, and when user click this button,an IBAction method connect to it with a Status param.

我想要的是,用户单击按钮并将状态传递给IBAction方法,在该方法中,我需要访问按钮的实例.

What I want is, user click button and pass the Status to the IBAction method, and in that method, I need access the instance of the button.

如何在没有(id)发送者的情况下获取按钮的实例?

How can I get the button's instance without an (id) sender here?

推荐答案

您可以像使用IBAction进行连接那样,将UIButton与插座连接起来.

You can wire up the UIButton with an outlet like you did with your IBAction to connect it.

在标题中添加:

UIButton *myButton;

...

@property (nonatomic, retain) IBOutlet UIButton *myButton;

然后将新插座与您在IB中的按钮链接.

And then link the new outlet with your button in IB.

然后,您可以在实例中使用myButton访问该按钮.

Then you can access the button with myButton in your instance.

这篇关于iPhone/目标C:如何从NIB获取UIButton实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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