Add tap on the descirption
I would like to add tap feature on the description label. So that I can either click the button or label to trigger the function.
But as if I add the UITapGestureRecognizer on the description, it is not working
Would you mind help me have a check for the method?
- (void)setDescriptionsTap
{
for (NSUInteger i=0; i<_descriptionsArray.count; i++)
{
[_descriptionsArray[i] setUserInteractionEnabled:true];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonActionForTap:)];
tapGesture.delegate = self;
[tapGesture.view setTag:i];
[_descriptionsArray[i] addGestureRecognizer:tapGesture];
}
}
Hi, I would need exactly the same behaviour when i click on the description and on the button. Is there any way to do that ?
Regards, Morgan
@morganbigot
I fixed this function now
`- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *view = nil;
for (LGPlusButton *button in _buttonsArray)
{
CGPoint newPoint = [self convertPoint:point toView:button];
view = [button hitTest:newPoint withEvent:event];
if (view) break;
}
if(!view){
for (LGPlusButtonDescription *description in _descriptionsArray)
{
CGPoint newPoint = [self convertPoint:point toView:description];
view = [description hitTest:newPoint withEvent:event];
if (view) break;
}
}
if (!view && _coverColor && !_coverView.isHidden)
{
CGPoint newPoint = [self convertPoint:point toView:_coverView];
view = [_coverView hitTest:newPoint withEvent:event];
}
return view;
}` By Adding these code, then you can add UITapGestureRecognizer function on the Description label with userInteractionEnabled = YES
Thank you!
Le 3 mars 2016 à 17:55, johnny51925 [email protected] a écrit :
@morganbigot
I fixed this function now
`- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { //NSLog(@"\nself = %@\nsuper = %@\nsubviews = %@\nsupersubviews = %@\n\n", self, [super hitTest:point withEvent:event], self.subviews, self.superview.subviews);
UIView *view = nil;
for (LGPlusButton *button in _buttonsArray) { CGPoint newPoint = [self convertPoint:point toView:button];
view = [button hitTest:newPoint withEvent:event]; if (view) break;}
if(!view){ for (LGPlusButtonDescription *description in _descriptionsArray) { CGPoint newPoint = [self convertPoint:point toView:description];
view = [description hitTest:newPoint withEvent:event]; if (view) break; }}
if (!view && _coverColor && !_coverView.isHidden) { CGPoint newPoint = [self convertPoint:point toView:_coverView];
view = [_coverView hitTest:newPoint withEvent:event];}
return view; }
`
By Adding these code, then you can add UITapGestureRecognizer function on the Description label with userInteractionEnabled = YES
— Reply to this email directly or view it on GitHub.
Hi,
Will you make an update of the POD with that fix ?
Regards,