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