2012-02-02 28 views
6

Tengo una aplicación con MKMapView y un código que se llama cada vez que el mapa cambia de ubicación (en regionDidChangeAnimated). Cuando la aplicación se carga inicialmente, se llama a regionDidChangeAnimated en paneles (toques), pellizcos, toques y botones que actualizan explícitamente las coordenadas del mapa. Después de cargar otras vistas y volver al mapa, la regiónDidChangeAnimated solo se solicita para los grifos y los botones que actualizan explícitamente el mapa. Al desplazarse por el mapa y pellizcar, ya no se llama a regionDidChangeAnimated.MKMapView Not calling regionDidChangeAnimated on Pan

He visto este stackoverflow post que no resolvió este problema. Las publicaciones del foro en devforums y iphonedevsdk tampoco funcionaron. ¿Alguien sabe qué causa este problema? No agrego ninguna subvista a MKMapView.

Respuesta

3

Yo no quiero inicialmente hacerlo de esta manera, pero parece funcionar sin problemas hasta el momento (tomadas de devforums puesto en cuestión):

añadir el UIGestureRecognizerDelegate a su cabecera. Ahora agregue un cheque por el número de versión ... Si estamos en IOS 4 podemos hacer esto:

if (NSFoundationVersionNumber >= 678.58){ 

     UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureCaptured:)]; 
     pinch.delegate = self;   
     [mapView addGestureRecognizer:pinch]; 

     [pinch release]; 

     UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCaptured:)]; 
     pan.delegate = self; 
     [mapView addGestureRecognizer:pan]; 

     [pan release]; 
} 

Añadir los métodos de delegado para manejar los gestos:

#pragma mark - 
#pragma mark Gesture Recognizers 

- (void)pinchGestureCaptured:(UIPinchGestureRecognizer*)gesture{ 
    if(UIGestureRecognizerStateEnded == gesture.state){ 
     ///////////////////[self doWhatYouWouldDoInRegionDidChangeAnimated]; 
    } 
} 

- (void)panGestureCaptured:(UIPanGestureRecognizer*)gesture{ 

    if(UIGestureRecognizerStateEnded == gesture.state){ 
     ///////////////////[self doWhatYouWouldDoInRegionDidChangeAnimated]; 
    } 
} 

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ 
    return YES; 
} 

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch: (UITouch *)touch{ 
    return YES; 
} 

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ 
    return YES; 
} 
+0

es que esto funciona en ¿Qué pasa con iOS 5 también? –

+0

Sí, tuve el problema con iOS 4 e iOS 5 y funciona en ambos. – brendan