Detecta 2 dedos en la pantalla en mapView MapKit

votos
0

Intento detectar el evento en una vista de mapa. Solo necesito detectar el zoom (doble toque o 2 dedos en la pantalla). Intento agregar una capa UIview que detecte un evento, pero si agrego una capa, pierdo el control en el mapa ( ¿Cómo se interceptan los eventos en un objeto MKMapView o UIWebView? )

¡Gracias por la ayuda!

Tony

Publicado el 22/09/2009 a las 17:37
fuente por usuario
En otros idiomas...                            


2 respuestas

votos
0

De acuerdo con esto: enlace de texto

Mkmapview tiene que ser el receptor predeterminado de los eventos.

Así que cambio la clase de mi ventana principal a MyMainWindow:

MyMainWindow.h

#import <Foundation/Foundation.h>
@class TouchListener;

@interface MyMainWindow : UIWindow {    

TouchListener *Touch;

}

@end 

MyMainWindow.m

 #import "MyMainWindow.h"

 @implementation MyMainWindow

 - (void)sendEvent:(UIEvent*)event {  
 [super sendEvent:event];  
 [Touch sendEvent:event];
 }
 @end

TouchListener.h

#import <Foundation/Foundation.h>
@interface TouchListener : UIView {

}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

@end

TouchListeners.m

#import "TouchListener.h"

@implementation TouchListener

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
 return self;
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 NSLog(@"Moved");
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Touch Began");
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Touch Ended");
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Touch Cancel");
}

@end

¿Me he perdido algo?

Gracias por la ayuda

Respondida el 24/09/2009 a las 22:49
fuente por usuario

votos
0

Muéstranos un código. Debería poder pasar cualquier evento que no le interese a la vista principal. Por ejemplo, después de detectar un toque con dos dedos y hacer lo que quieras, pasa ese mismo evento a la vista de mapa y haz que se amplíe.

Esto es lo que llamas una vez que hayas terminado con la detección de tu evento:

[self.nextResponder touchesBegan:touches withEvent:event];
Respondida el 23/09/2009 a las 08:59
fuente por usuario

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more