Question

I'm want to add button into UIImageView. Added button not active.

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];

Handler:

- (void)buttonPress1:(id)sender
{
    NSLog(@"1");
}

What's wrong?

Was it helpful?

Solution

Did you try:

iview.userInteractionEnabled = YES;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top