【发布时间】:2012-11-08 15:06:03
【问题描述】:
我有一个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{
//....
}
【问题讨论】:
-
我模拟了你提到的工作,但它对我来说工作正常
-
对我来说不起作用。没有 UIView 一切正常,但是这个 UIView 是缩放所必需的
标签: ios uiview uiscrollview uibutton