LGPlusButtonsView icon indicating copy to clipboard operation
LGPlusButtonsView copied to clipboard

Add tap on the descirption

Open johnny51925 opened this issue 9 years ago • 4 comments

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];

    }
}

johnny51925 avatar Feb 15 '16 09:02 johnny51925

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 avatar Feb 15 '16 11:02 morganbigot

@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

johnny51925 avatar Mar 03 '16 16:03 johnny51925

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.

morganbigot avatar Mar 04 '16 06:03 morganbigot

Hi,

Will you make an update of the POD with that fix ?

Regards,

morganbigot avatar Mar 08 '16 09:03 morganbigot