我有一个将UIView作为子视图的scrollView.这有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{ //.... }