UIView subView按钮未激活

时间:2014-03-15 19:18:29

标签: ios uiview addsubview

我想在UIImageView中添加按钮。添加的按钮未激活。

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");
}

出了什么问题?

1 个答案:

答案 0 :(得分:2)

你有没有尝试过:

iview.userInteractionEnabled = YES;