0
我有一个自定义视图,例如ParentView
:UIView
。这里面视图我有一个UIButton
是我加入编程为无法在自定义UIView上单击UIButton
UIButton *btn = [[UIButton alloc] initWithFrame:frame];
[btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpOutside];
[self addSubview:btn];
和行动:
-(void)buttonPressed:(id)sender{
NSLog(@"button pressed: %@",sender);
}
在我的故事板我有一个基本观点,它的类我已经设置为ParentView。初始化确实被调用,并且UIButton创建正常,只是该操作未被调用。 ParentView已检查userInterActionEnabled
。
啊,xcode的自动补全帮助一个可怕的错字,谢谢 – Axarydax