私は2つの異なるビューで同時に2つのtouchesBegan
イベントを呼び出すことが正確にどのようにわからないんだけど、あなたはおそらくUIView
のhitTest:withEvent:
メソッドをオーバーライドします。これにより、のタッチイベントがのUIButton
の前に表示され、の前にボタンが表示されます(ヒットテストの動作は、window
から最前面に表示されます)。
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (passToSubviews)
{
return [super hitTest: point withEvent: event];
}
// otherwise stop the subview receiving touches
if ([super hitTest: point withEvent: event])
{
return self;
}
return nil;
}
多分これは助けることができる...
EDIT:
だけの推測が、あなたは試みることができる:
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView* hitSubview = [super hitTest: point withEvent: event];
if (hitSubview)
{
[self doTouchedInStuff];
return hitSubview;
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self doTouchedInStuff];
[super touchesBegan:touches withEvent:event];
}
出典
2011-08-04 10:19:23
Sam
passToSubviewを?このメソッドをオーバーライドするだけで違いが生まれますか? – Tornado
はいこれにより、タッチが検出される場所を定義できますが、同時に2つの異なるビューでタッチを検出することはできません – Sam
すべて完了....ありがとう – Tornado