我有scrollView
一个UIView
作为子视图的。这有UIView
一个子视图UIButton
。只有scrollView
连接到插座,其余全部在代码中。按钮不响应触摸,触摸时不变为蓝色。我该怎么做才能让它发挥作用?
这是代码:
- (void)viewDidLoad
{
[super viewDidLoad];
//......
self.buttonHome = [UIButton buttonWithType:UIButtonTypeCustom];
[self.buttonHome addTarget:self action:@selector(pressedHome:)
forControlEvents:UIControlEventTouchUpInside];
//....
self.containerView =[[UIView alloc]initWithFrame:self.scrollView.frame];
self.containerView.userInteractionEnabled=YES;
[self.scrollView addSubview:self.containerView];
[self.containerView addSubview:self.buttonHome];
}
-(void) pressedHome:(id)sender{
//....
}