2009-09-22 55 views

回答

0

向我們展示一些代碼。您應該能夠將您不感興趣的任何事件傳遞迴父視圖。例如,在您檢測到兩個手指點擊並做任何您想要的操作之後,將相同的事件傳遞迴mapview並將其自動放大。

這裏是你所說的,一旦你與你的事件檢測完成:

[self.nextResponder touchesBegan:touches withEvent:event]; 
0

根據此:link text

的的MKMapView必須是事件的默認接收器。

所以我改變了我的類主窗口到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 

我錯過了什麼?

感謝您的幫助