Monday, July 7, 2014

Iphone: Tap Gesture recognizer on a view

UITapGestureRecognizer *tapGR;
tapGR = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)] autorelease];
tapGR.numberOfTapsRequired = 1;
[myUIView addGestureRecognizer:tapGR];

// Add a delegate method to handle the tap and do something with it.
-(void)handleTap:(UITapGestureRecognizer *)sender
{
    if (sender.state == UIGestureRecognizerStateEnded) {
        // handling code
    }
}

No comments:

Post a Comment