From 8d9572a5939fb5e0dd3d306c00805978849631b6 Mon Sep 17 00:00:00 2001 From: Andrei Senchuk Date: Tue, 13 Oct 2015 11:46:46 +0300 Subject: [PATCH 1/2] fix issue with getting wrong indexPath when KILabel is used in the UITableView cell --- KILabel/Source/KILabel.m | 4 --- .../KILabelDemo/Base.lproj/Main.storyboard | 36 +++++++++++++------ .../KILabelDemo/KILabelTableViewController.m | 5 +++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/KILabel/Source/KILabel.m b/KILabel/Source/KILabel.m index 37dbbff..523fb2e 100644 --- a/KILabel/Source/KILabel.m +++ b/KILabel/Source/KILabel.m @@ -681,10 +681,6 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event [self receivedActionForLinkType:linkType string:touchedSubstring range:range]; } - else - { - [super touchesBegan:touches withEvent:event]; - } self.selectedRange = NSMakeRange(0, 0); } diff --git a/KILabelDemo/KILabelDemo/Base.lproj/Main.storyboard b/KILabelDemo/KILabelDemo/Base.lproj/Main.storyboard index 1279791..0027379 100644 --- a/KILabelDemo/KILabelDemo/Base.lproj/Main.storyboard +++ b/KILabelDemo/KILabelDemo/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -18,6 +19,7 @@ + @@ -128,23 +140,28 @@ - + + - + + + + @@ -152,6 +169,7 @@ + @@ -177,6 +195,7 @@ + @@ -189,9 +208,4 @@ - - - - - diff --git a/KILabelDemo/KILabelDemo/KILabelTableViewController.m b/KILabelDemo/KILabelDemo/KILabelTableViewController.m index 27417bf..70228b9 100644 --- a/KILabelDemo/KILabelDemo/KILabelTableViewController.m +++ b/KILabelDemo/KILabelDemo/KILabelTableViewController.m @@ -94,6 +94,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N return cell; } +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSLog(@"Selected row indexPath: %@", indexPath); +} + /** * Called when a link is tapped. * From e6d4552c854280477468f2bdc7c6554b8e7d64e7 Mon Sep 17 00:00:00 2001 From: Andrei Senchuk Date: Thu, 12 Nov 2015 12:41:18 +0300 Subject: [PATCH 2/2] Fix crash caused by nil color --- KILabel/Source/KILabel.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/KILabel/Source/KILabel.m b/KILabel/Source/KILabel.m index 523fb2e..e1f0801 100644 --- a/KILabel/Source/KILabel.m +++ b/KILabel/Source/KILabel.m @@ -353,11 +353,17 @@ - (NSDictionary *)attributesFromProperties paragraph.alignment = self.textAlignment; // Create the dictionary - NSDictionary *attributes = @{NSFontAttributeName : self.font, - NSForegroundColorAttributeName : color, - NSShadowAttributeName : shadow, - NSParagraphStyleAttributeName : paragraph, - }; + NSMutableDictionary *attributes = @{ + NSFontAttributeName : self.font, + NSShadowAttributeName : shadow, + NSParagraphStyleAttributeName : paragraph, + }.mutableCopy; + + if (color) + { + attributes[NSForegroundColorAttributeName] = color; + } + return attributes; }