开发者

UILongPressGestureRecognizer of Superview gets called instead of Subview

i got a strange problem. I got a Superview with customcontrols as subviews. Their are GestureRecognizer both in superview and subviews.

If i tap a subview its GestureRecognizer gets called and on tap on the superview its tap gets called.

but on long press in the subview SOMETIMES the GestureRecognizer of the superview gets called. I add the GestureRecognizers in the same functions but there is a different attitude.

Superview

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapPiece:)];
tapGesture.numberOfTapsRequired = 1;
//contenView is the area where my controls can be
[self.contentView addGestureRecognizer:tapGesture];
[tapGesture release];

UILongPressGestureRecognizer *longTapGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTapPiece:)];
tapGesture.numberOfTapsRequired = 1;
[self.contentView addGestureRecognizer:longTapGesture];
[longTapGesture release];

Subviews

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectPiece:)];
tapGesture.numberOfTapsRequired = 1;
[self addGestureRecognizer:tapGesture];

UILongPressGestureRecog开发者_如何学Cnizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPiece:)];
longPressGesture.numberOfTapsRequired = 1;
[self addGestureRecognizer:longPressGesture];

Can anyone tell me why the longtap doen't response to my subview and how to fix it.

THANK YOU


got a solution but this is not what i wanted i set the duration of the control lower than the one of the superview [longPressGesture setMinimumPressDuration:0.4]; But the gestureRecognizer should be independend

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜