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

KILabel lead to a wrong index for didSelectRowAtIndexPath #57

Open
zzyhappyzzy opened this issue Jan 21, 2016 · 2 comments
Open

KILabel lead to a wrong index for didSelectRowAtIndexPath #57

zzyhappyzzy opened this issue Jan 21, 2016 · 2 comments

Comments

@zzyhappyzzy
Copy link

lead a wrong index when select between cells。
KILabel which on a tableviewCell contentView lead to a wrong index for didSelectRowAtIndexPath

@Guferos
Copy link

Guferos commented Jan 21, 2016

It was already explained in other ticket. There is a typo in touchesEnded:withEvent method.

You need to replace line 686:
[super touchesBegan:touches withEvent:event];

with:
[super touchesEnded:touches withEvent:event];

I have also moved [super touchesEnded:touches withEvent:event]; call from line 661 to line 667.

The final touchesEnded:withEvent method should look like this:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    // If the user dragged their finger we ignore the touch
    if (_isTouchMoved)
    {
        self.selectedRange = NSMakeRange(0, 0);
        [super touchesEnded:touches withEvent:event];
        return;
    }

    // Get the info for the touched link if there is one
    NSDictionary *touchedLink;
    CGPoint touchLocation = [[touches anyObject] locationInView:self];
    touchedLink = [self linkAtPoint:touchLocation];

    if (touchedLink)
    {
        NSRange range = [[touchedLink objectForKey:KILabelRangeKey] rangeValue];
        NSString *touchedSubstring = [touchedLink objectForKey:KILabelLinkKey];
        KILinkType linkType = (KILinkType)[[touchedLink objectForKey:KILabelLinkTypeKey] intValue];

        [self receivedActionForLinkType:linkType string:touchedSubstring range:range];
    }
    else
    {
        [super touchesEnded:touches withEvent:event];
    }

    self.selectedRange = NSMakeRange(0, 0);
}

@zzyhappyzzy
Copy link
Author

Thanks for your reply !
Best Regards !

在 2016年1月21日,下午9:42,Damian Wojtczak notifications@github.com 写道:

It was already explained in other ticket. There is a typo in touchesEnded:withEvent method.

You need to replace line 686:
[super touchesBegan:touches withEvent:event];

with:
[super touchesEnded:touches withEvent:event];

I have also moved [super touchesEnded:touches withEvent:event]; call from line 667 to line 667.

The final touchesEnded:withEvent method should look like this:

  • (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
    // If the user dragged their finger we ignore the touch
    if (_isTouchMoved)
    {
    self.selectedRange = NSMakeRange(0, 0);
    [super touchesEnded:touches withEvent:event];
    return;
    }

    // Get the info for the touched link if there is one
    NSDictionary *touchedLink;
    CGPoint touchLocation = [[touches anyObject] locationInView:self];
    touchedLink = [self linkAtPoint:touchLocation];

    if (touchedLink)
    {
    NSRange range = [[touchedLink objectForKey:KILabelRangeKey] rangeValue];
    NSString *touchedSubstring = [touchedLink objectForKey:KILabelLinkKey];
    KILinkType linkType = (KILinkType)[[touchedLink objectForKey:KILabelLinkTypeKey] intValue];

    [self receivedActionForLinkType:linkType string:touchedSubstring range:range];
    

    }
    else
    {
    [super touchesEnded:touches withEvent:event];
    }

    self.selectedRange = NSMakeRange(0, 0);
    }

    Reply to this email directly or view it on GitHub KILabel lead to a wrong index for didSelectRowAtIndexPath #57 (comment).

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