Detect 2 degete pe ecran pe mapView MapKit

voturi
0

Încerc să detecteze evenimentul pe un mapview. Am nevoie doar pentru a detecta zoom (apăsați de două ori sau de 2 degete pe ecran). Încerc să adăugați un strat care detectează UIView eveniment, dar dacă am adăuga un strat, am pierdut controlul pe hartă ( Cum de a intercepta evenimente atinge pe un MKMapView sau UIWebView obiecte? )

Multumesc pentru ajutor!

Tony

Întrebat 22/09/2009 la 17:37
sursa de către utilizator
În alte limbi...                            


2 răspunsuri

voturi
0

Conform acestui: link text

Mkmapview trebuie să fie receptorul implicit a evenimentelor.

Așa că am schimba clasa de fereastra mea principală la 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

Am pierdut ceva?

Multumesc pentru ajutor

Publicat 24/09/2009 la 22:49
sursa de către utilizator

voturi
0

Arată-ne un cod. Tu ar trebui să poată să treacă orice evenimente care nu sunt interesați înapoi la afișarea părinte. De exemplu, după ce detectează două degete de la robinet, și fă ce vrei, treci același eveniment înapoi la mapview și să-l în sine zoom.

Iată ce te sun odată ce ați terminat cu detectarea evenimentului:

[self.nextResponder touchesBegan:touches withEvent:event];
Publicat 23/09/2009 la 08:59
sursa de către utilizator

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