0

UIButton タッチを転送するためのこのコードが iOS5 で機能しなくなった理由を理解できないようです。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    [self.nextResponder touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];
    [self.nextResponder touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
    [self.nextResponder touchesEnded:touches withEvent:event];
}

次のレスポンダーのタッチ メソッドをログに記録すると、移動したタッチは 1 回だけ転送され、終了したタッチはまったく転送されないことがわかります。iOS4 ではすべてのタッチが転送されるため、これは非常に予期しない動作です。どんな助けでも大歓迎です。

4

1 に答える 1

0

コメント投稿者はテストでこのコードを正常に動作させることができましたが、私は iOS5 で確実に動作させることができませんでした。私の解決策は、委任を使用して、関係者にタッチを転送することでした。エレガントでも好まれてもいませんが、これまでのところ問題なくうまく機能しています。

于 2012-10-24T14:57:06.520 に答える