Cyril
Cyril

Reputation: 1236

Separate the Tap Event from the ImageView

I am having a View where the TapGestureRecognizer is used. I am using the TapGestureRecognizer for the Single and double tap event. So far so good. Now I have added a ImageView on Top of the View , the image view frame is imageView.frame=CGRectMake(50,290,205,100);

Now wherever I am tapping the View , my @selectors being called. I want to skip the tap events only for the ImageView . How to do it ?

I tried using the

if(recognizer.state == UIGestureRecognizerStateRecognized)
{
    CGPoint point = [recognizer locationInView:recognizer.view];
}

Upvotes: 0

Views: 116

Answers (4)

Murali
Murali

Reputation: 1889

Do this...I hope this will help you...

Whenever you tap on screen this delegate method will call..

in this method please check touch and gestureRecognizer will give some data regarding your tapping..... Based on that you can proceed.....

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    NSLog(@"%@",touch.description);
    NSLog(@"%@",gestureRecognizer.description);
}

Upvotes: 2

ASP
ASP

Reputation: 88

You have to implement this check

if(!CGRectContainsPoint(image.view.frame, point))
  {
     //Complete your Work
   }

Upvotes: 2

Paresh Navadiya
Paresh Navadiya

Reputation: 38239

Do this:

if(recognizer.state == UIGestureRecognizerStateRecognized)
{
    CGPoint point = [recognizer locationInView:recognizer.view];
    if(CGRectContainsPoint(imageView.frame,point)
    {
       //igonre
    }
    else
    {
      // continue
    }
}

Upvotes: 1

Dushyant Singh
Dushyant Singh

Reputation: 721

You need to check for the touch point ,

if(!CGRectContainsPoint(image.view.frame, point))
   {
      //Do you work here
    }

Upvotes: 1

Related Questions