在我的情况下,是class C的子类,是 的子类UIViewController,具有. 我写了一些如下代码。class A and BUIViewclass AUIButton
在class C:
B *b = [[B alloc] init];
[self.view addSubView:b];
A *a = [[A alloc] initWithTarget:self action:@Selector(methodX:)];
[b methodY:a];
在class B:
- (void)methodY:(A *)a
{
[sef addSubView:a];
}
在class A:
- (id)initWithTarget:(id)target action:(SEL)action
{
self = [super initWithFrame:frame];
UIButton *btn = [[UIButton alloc] init];
[btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
[self addSubView:btn];
return self;
}
methodX:inclass C没有执行。
我的代码有什么问题吗?
选择器如何在 Objective-C 中工作?
谢谢!