0

マップビューでイベントを検出しようとしています。ズームを検出する必要があるだけです(画面上でダブルタップまたは2本の指)。イベントを検出する UIview レイヤーを追加しようとしましたが、レイヤーを追加すると、マップ上のコントロールが失われます ( MKMapView または UIWebView オブジェクトでタッチ イベントをインターセプトする方法は? )

手伝ってくれてありがとう!

トニー

4

2 に答える 2

0

これによると:リンクテキスト

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

私は何か見落としてますか?

手伝ってくれてありがとう

于 2009-09-24T21:49:13.820 に答える
0

コードを見せてください。興味のないイベントを親ビューに戻すことができるはずです。たとえば、2 本の指でのタップを検出し、必要なことを行った後、同じイベントを mapview に戻し、それ自体をズームさせます。

イベント検出が完了したら、次のように呼び出します。

[self.nextResponder touchesBegan:touches withEvent:event];
于 2009-09-23T07:59:08.593 に答える