Ios UIView子视图按钮未激活
我想在UIImageView中添加按钮。添加的按钮未激活Ios UIView子视图按钮未激活,ios,uiview,addsubview,Ios,Uiview,Addsubview,我想在UIImageView中添加按钮。添加的按钮未激活 UIImageView *iview = [[UIImageView alloc] initWithImage:image]; iview.frame = [[UIScreen mainScreen] applicationFrame]; iview.contentMode = UIViewContentModeTopLeft; UIButton *bview1 = [UIButton buttonWithType:UIButtonTy
UIImageView *iview = [[UIImageView alloc] initWithImage:image];
iview.frame = [[UIScreen mainScreen] applicationFrame];
iview.contentMode = UIViewContentModeTopLeft;
UIButton *bview1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
bview1.frame = CGRectMake(0, 0, 200, 60);
bview1.center = CGPointMake(100, 100);
[bview1 addTarget:self action:@selector(buttonPress1:) forControlEvents:UIControlEventTouchUpInside];
[bview1 setTitle:@"Image Picker1" forState:UIControlStateNormal];
[iview addSubview:bview1];
[self.view addSubview:iview];
处理程序:
- (void)buttonPress1:(id)sender
{
NSLog(@"1");
}
怎么了?您是否尝试过:
iview.userInteractionEnabled = YES;
UIImageView的默认userInteractionEnabled==否,因此答案是正确的。没问题,感谢您接受答案,我很高兴它能工作!