我有一个scrollView
,它有一个UIView
作为子视图。这有UIView
子视图UIButton
。只有scrollView
连接到插座,其余全部在代码中。按钮不响应触摸,触摸时不会变为蓝色。我能做些什么来使它工作?UIButton在uiscroll中不起作用查看
这是代码:
- (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{
//....
}
我模拟你提到的工作,但它对我来说工作正常 –
对我而言无效。没有UIView完美的工作,但这个UIView是必要的缩放 –