0

UIWindowをサブクラス化しましたが、何らかの理由で、画面との対話のために-(void)sendEvent:(UIEvent *)eventが2回呼び出されます。なぜそれが起こるのでしょうか?

4

2 に答える 2

2

デバッグの目的で、(アプリデリゲートの)ウィンドウをサブクラス化し、sendEvent:メソッドをオーバーライドします

-(void) sendEvent:(UIEvent *)event
{
    NSLog(@"%@",event);
    [super sendEvent:event];
}

おそらく、TouchesBeganとTouchesEnded(タップ用)の原因となるイベントに気付くでしょう。これは、ビューをサブクラス化し、タッチ関連のメソッドをオーバーライドすることでテストできます。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"tocuhesBegan");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesMoved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesCancelled");
}

また、ビューをドラッグ/スワイプして、ビューに送信されたイベントの数の変化を確認してください:)

于 2012-05-18T00:33:46.177 に答える
0

sendEventはfingerDownとallFingersUpに対して呼び出されます

于 2012-05-18T00:15:46.717 に答える