Skip to content

Add tap on the descirption #24

Open

Description

@johnny51925

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

    }
}

Activity

  1. morganbigot commented on Feb 15, 2016

    @morganbigot

    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

  2. johnny51925 commented on Mar 3, 2016

    @johnny51925
    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

  3. morganbigot commented on Mar 4, 2016

    @morganbigot

    Thank you!

    Le 3 mars 2016 à 17:55, johnny51925 notifications@github.com 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.

  4. morganbigot commented on Mar 8, 2016

    @morganbigot

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions