Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tap on the descirption #24

Open
johnny51925 opened this issue Feb 15, 2016 · 4 comments
Open

Add tap on the descirption #24

johnny51925 opened this issue Feb 15, 2016 · 4 comments

Comments

@johnny51925
Copy link

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

    }
}

@morganbigot
Copy link

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

@johnny51925
Copy link
Author

@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

@morganbigot
Copy link

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
Copy link

Hi,

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

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants