Open zzyhappyzzy opened 8 years ago
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);
}
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 https://github.com/Krelborn/KILabel/issues/57#issuecomment-173573262.
lead a wrong index when select between cells。 KILabel which on a tableviewCell contentView lead to a wrong index for didSelectRowAtIndexPath