GestureRecognizers on different subviews with defined indexes
I have a view with multiple subviews. In controller, i add pinch, pan and
zoom to one view:
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(panAction:)];
[panGesture setMinimumNumberOfTouches:1];
[panGesture setMaximumNumberOfTouches:1];
[panGesture setDelegate:self];
[_view1 addGestureRecognizer:panGesture];
UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]
initWithTarget:self action:@selector(pinchAction:)];
[pinchGesture setDelegate:self];
[_view1 addGestureRecognizer:pinchGesture];
UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer
alloc] initWithTarget:self action:@selector(rotateAction:)];
[rotateGesture setDelegate:self];
[_view1 addGestureRecognizer:rotateGesture];
Later i'm adding multiple subviews and add tap gesture recognizer on all
of them:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(tapAction:)];
[tapGesture setDelegate:self];
for (UIView *view in views) {
[view setUserInteractionEnabled:YES];
[view setMultipleTouchEnabled:NO]; // tried setting YES, both don't
change anything
[view addGestureRecognizer:tapGesture];
[self.view insertSubview:view atIndex:changingIndexVariable];
}
My class is also a delegate of UIGestureRecognizerDelegate:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer
*)otherGestureRecognizer {
return YES;
}
The problem is that only first view of self.views receives the touch. Eg i
try to zoom (what is only on _view1) but on top i have one of views from
array - zooming isn't working. I can switch to that view though. On
oppsite situation, when _view1 is the top view, zoom etc is working ok
however i can't get make tapAction called.
What to do to make all of them working?
No comments:
Post a Comment