iOS - 从其超类设置 UIButton 目标和操作 [英] iOS - set UIButton target and action from its super class

查看:21
本文介绍了iOS - 从其超类设置 UIButton 目标和操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两节课A类:UIViewClassB:UIViewController

I have 2 classes ClassA: UIView ClassB: UIViewController

我在 ClassA 中有一个 UIButton

I have a UIButton in ClassA

按钮在标题中声明并作为A的@property

The button is declared in the header and as an @property of A

UIButton *selectBtn;    
}
@property (nonatomic, strong) UIButton *selectBtn;

在 A 类的 .m 文件中,按钮被初始化并显示在屏幕上

in the .m file of Class A the button is initialized and shows up on screen

ClassB 导入 ClassA 的头文件,我正在尝试使用以下内容为我的按钮设置目标和操作

ClassB imports ClassA's header file and from it I'm trying to set the target and the action for my button with the following

[ClassA.selectBtn addTarget:self action:@selector(getSomething:)     forControlEvents:UIControlEventTouchUpInside];

但我不断收到错误消息说在ClassA"类型的对象上找不到属性"selectBtn

But i keep getting an Error message saying "Property "selectBtn" not found on object of type "ClassA"

我做错了什么?非常感谢任何帮助或指导

What am I doing wrong ? any help or guidance is very appreciated

推荐答案

[ClassA.selectPicBtn addTarget:self action:@selector(getSomething:)     forControlEvents:UIControlEventTouchUpInside];

使用 selectPicBtn 代替 selectBtn

use selectPIcBtn instead of selectBtn

这篇关于iOS - 从其超类设置 UIButton 目标和操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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