Intercepting/Hijacking iPhone Touch Events for MKMapView

后端 未结 6 1435
故里飘歌
故里飘歌 2020-12-01 05:56

Is there a bug in the 3.0 SDK that disables real-time zooming and intercepting the zoom-in gesture for the MKMapView? I have some real simple code so I can detect tap event

6条回答
  •  我在风中等你
    2020-12-01 06:15

    I had the same problem - I wanted to draw map scales on top of Map View. In order to do it I had to intercept the touch events, and then send them back to the Map View. Unfortunately, when the MKMapView isn't the original receiver of the events, some smooth panning and zooming animations are not working any more.

    However I have found a solution to this problem - a bit hacky but works: 1. I have put my MapScales UIView on top of MKMapView, and turned off receiving events in it, so that underlying MKMapView received the events by default. 2. I have subclassed UIWindow with MyMainWindow class and in it I have overriden the method:

    - (void) sendEvent:(UIEvent*)event {
      [super sendEvent:event];
      [self send_the_event_also_to_my_MapScales_component_with_use_of_listener_design_pattern];
    }
    
    1. I have made the main window of my application an instasnce of MyMainWindow.

    In this way my MapScales component receives and can react to all the touch events, and at the same time it is not spoiling the underlying MKMapView :)

提交回复
热议问题