Search code examples
iphoneobjective-ciosuitouch

Mapview touch is not getting detected in ios


I have a mapview in my xib.

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    NSLog(@"Touch Description %@",[[touch view]description]);
    if ([touch view]  == self.mapView) 
   {
      //rest of my code
   }
}

The description that I get is

MKAnnotationContainerView: 0x19057360; frame = (0 0; 4096 4096); autoresizesSubviews = NO; layer = CALayer: 0x1900df20

The if Loop is not being executed. How can I solve this. Please help me.


Solution

  •     -(void) touchesBegan :(NSSet *) touches withEvent:(UIEvent *)event
        {
            UITouch *touch = [touches anyObject];
            NSLog(@"%@",[[touch view]description]);
            if ([touch view]  == self.mapView) 
           {
               //rest of my code
           }
    
           [super touchesBegan:touches withEvent:event ];
        }