MapView MapKit üzerindeki ekranda 2 parmak Algılama

oy
0

Bir MapView olayı algılamaya çalışırız. Sadece zoom (çift dokunun veya ekranda 2 parmak) algılamak gerekir. Ben olayı algılamak UIView katmanı eklemek için çalışıyorum ama bir katman eklerseniz, ben harita üzerinde kontrolünü kaybetmek ( Nasıl MKMapView veya UIWebView nesneler üzerinde dokunuşlar olayları önünü? )

Yardım için teşekkürler!

Tony

Oluştur 22/09/2009 saat 17:37
kaynak kullanıcı
Diğer dillerde...                            


2 cevaplar

oy
0

Bu göre bağlantı metnini

Mkmapview olayların varsayılan alıcı olmak zorunda.

Bu yüzden MyMainWindow benim ana pencerenin sınıfını değiştirin:

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

Bir şey mi kaçırdım?

Yardım için teşekkürler

Cevap 24/09/2009 saat 22:49
kaynak kullanıcı

oy
0

Bize biraz kod göster. Eğer ebeveyn görünümüne arka ilgilenmiyor herhangi olayları geçmek mümkün olmalıdır. Örneğin, senden sonra bir iki parmakla dokunma algılamak ve istediğini yapmak, MapView geri aynı olayı geçmek ve kendini Büyütmek var.

Burada olay algılama kez yapılır diyoruz:

[self.nextResponder touchesBegan:touches withEvent:event];
Cevap 23/09/2009 saat 08:59
kaynak kullanıcı

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