-2

Hello I am trying to add a tap to start image like the one in flappy birds but I cant really find what I'm looking for on the webs so I came here. I have tried using UIImageView to do this but it doesn't work.

Does anyone know how to do this?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
John paul
  • 69
  • 6

2 Answers2

1

You can do this task this way. When you add image add a transparent button over imageView and then from the button's action start the activity.

Code for transparent button

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
Arjun Chaudhary
  • 2,373
  • 2
  • 19
  • 36
0

Add a UITapGestureRecognizer to the UIImageView and set the UIImageView's userInteractionEnabled to YES.

Try this

imageView.userInteractionEnabled = YES;

UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped)];
[imageView addGestureRecognizer:tapGesture];
[tapGesture release];

and implement this

- (void)viewTapped:(UITapGestureRecognizer *)gestureRecognizer
{
    UIView *tappedView = gestureRecognizer.view;
}
Francesco Puglisi
  • 2,140
  • 2
  • 18
  • 26