UIImageView上添加Button不能响应点击事件[转]
View Code
1 UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-UITABBAR_HEIGHT-216-39, 320, 43) ]; 2 [backImageView setUserInteractionEnabled:YES];//使添加其上的button有点击事件 3 [backImageView setImage:[UIImage imageNamed:@"navigationBar.png"]]; 4 [backScroll addSubview:backImageView]; 5 6 UIButton *loginButton = [UIButton alloc]; 7 [loginButton setFrame:CGRectMake(10, 0, 40, 43)]; 8 [loginButton setTitle:@"hello" forState:UIControlStateNormal]; 9 [loginButton addTarget:self action:@selector(loginOrLogout) forControlEvents:UIControlEventTouchUpInside]; 10 [backImageView addSubview:loginButton
以上代码是在一张图片上面添加按钮,并让按钮在图片上面能够响应按钮的事件的做法。
吾屋无污,吴捂屋污,诬吾污屋,吾晤吴污,吾无物污,吴侮污吾,吾忤吴屋,悟吴诬吾,污屋吴污,吴侮吾污,吾勿武侮,吾唔吴误,诬侮污吾,吾屋悟忤.