I am trying to using UIPanGestureRecognizer and UITapGestureRecognizer on UISlider. tap is working fine i am facing problem with UIPanGestureRecognizer. I need to call handleTransactionPan method on changing value of UISlider but it is never being called because of its delegate method.
How can i invoke the selector while keeping the delegate methods to fire? Here is the code for what i have done so far.
- (void)viewDidLoad
{
[super viewDidLoad];
pr=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleTransactionPan:)];
pr.delegate=self;
[slider addGestureRecognizer:pr];
tr=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tr.delegate=self;
[slider addGestureRecognizer:tr];
}
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
return YES;
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if(gestureRecognizer==pr)
{
if ([touch.view isKindOfClass:[UISlider class]]) {
return NO;
}
}
return YES;
}