Adr*_*lli 7 uibutton uiscrollview uiview ios
我有一个scrollView具有UIView作为子视图.这有UIView子视图a 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{
//....
}
Run Code Online (Sandbox Code Playgroud)
我解决了
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
return ![view isKindOfClass:[UIButton class]];
}
Run Code Online (Sandbox Code Playgroud)
由于问题是放置一个按钮 UIButton
| 归档时间: |
|
| 查看次数: |
9234 次 |
| 最近记录: |