I am using following code
@property (retain, nonatmoic) UIImageView *imgView;
if ( count == 6)
{
[timer invalidate];
imgView= [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,460)];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
imgView.image = [UIImage imageNamed:@"ipad_popover-incorrectguess.png"];
[self.view addSubview:imgView];
}
else if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
imgView.image = [UIImage imageNamed:@"iphone_popover-incorrectguess.png"];
[self.view addSubview:imgView];
}
UIGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(newRound)];
[imgView addGestureRecognizer:tap];
}
}
-(void)newRound
{
[imgView removeFromSuperview];
}
it seems that newROUND Is never called when I tap anywhere on the image.
How can i fix that?
You need to enable user interaction for imgView:
Unlike a UIView, a UIImageView’s userInteractionEnabled property is set to NO by default, so you need to explicitly set it to YES to have it receive touches.