Rileva 2 dita sullo schermo su MapView MapKit

voti
0

Cerco di rilevare l'evento su un mapview. Ho solo bisogno di rilevare zoom (doppio tap o 2 dita sullo schermo). Cerco di aggiungere uno strato UIView che rilevano evento, ma se aggiungo un livello, perdo il controllo sulla mappa ( Come intercettare tocchi eventi su un MKMapView o UIWebView oggetti? )

Grazie per l'aiuto!

Tony

È pubblicato 22/09/2009 alle 17:37
fonte dall'utente
In altre lingue...                            


2 risposte

voti
0

Secondo questo: testo del link

Il Mkmapview deve essere il destinatario di default degli eventi.

Così ho cambiare la classe della mia finestra principale per 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

Ho dimenticato qualcosa?

Grazie per l'aiuto

Risposto il 24/09/2009 a 22:49
fonte dall'utente

voti
0

Mostraci po 'di codice. Si dovrebbe essere in grado di superare tutti gli eventi che non sono interessati a tornare alla vista primaria. Ad esempio, dopo aver rilevare un rubinetto a due dita, e fare quello che vuoi, passare lo stesso evento torna a mapview e farlo diminuire stessa.

Ecco quello che si chiama una volta che hai finito con il vostro rilevamento di un evento:

[self.nextResponder touchesBegan:touches withEvent:event];
Risposto il 23/09/2009 a 08:59
fonte dall'utente

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