Actually, I'm trying to remove the deprecated code from my app (Modifying the target deployment from iOS6 to iOS7) and I'm looking for alternatives. Here is the old code:
- (void) mapTapped:(UITapGestureRecognizer *)sender
{
CMELog(@"mapTapped");
if (sender.state != UIGestureRecognizerStateEnded)
return;
CGPoint mapTouchPoint = [sender locationInView:mainMapView];
CLLocationCoordinate2D mapTouchCoord = [mainMapView convertPoint:mapTouchPoint toCoordinateFromView:mainMapView];
MKMapPoint touchMapPoint = MKMapPointForCoordinate(mapTouchCoord);
CMELog(@"touchMapPoint: x:%f, y:%f", touchMapPoint.x, touchMapPoint.y);
// this is where things can get inefficient if you have loads of overlayViews that aren't even visible!
for (id<MKOverlay> overlay in self.mainMapView.overlays)
{
MKOverlayView *overlayView = [self.mainMapView viewForOverlay:overlay];
CGSize overlayViewSize = overlayView.frame.size;
CGPoint touchPoint = [sender locationInView:overlayView];
// check to see if the point is within the overlay bounding box first
if (touchPoint.x > 0 && touchPoint.x < overlayViewSize.width && touchPoint.y > 0 && touchPoint.y < overlayViewSize.height)
{
}
}
}
I replaced the first line in the loop by the following:
MKOverlayRenderer *rendererOverlay = [self.mainMapView rendererForOverlay:overlay];
But I could not find how to get the frame of the render overlay. Any idea please?