From 91590d9aac1f686f078f95a1e6940e191c9fac4e Mon Sep 17 00:00:00 2001 From: homekuanyi Date: Thu, 17 Sep 2015 13:25:18 +0800 Subject: [PATCH] fix: @selector(characterIndexAtPoint:) return the right index of UILabel in Truncate* mode when auto-wrap. --- .../AttributedStringDemo/ASDViewController.m | 1 + .../AttributedStringDemo/ASDViewController.xib | 9 ++++----- Source/UILabel+OHAdditions.m | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Example/AttributedStringDemo/ASDViewController.m b/Example/AttributedStringDemo/ASDViewController.m index 14923a5..f8b1a68 100644 --- a/Example/AttributedStringDemo/ASDViewController.m +++ b/Example/AttributedStringDemo/ASDViewController.m @@ -128,6 +128,7 @@ - (IBAction)tapOnFooter:(UITapGestureRecognizer *)tapGR NSUInteger pos = [self.footerLabel characterIndexAtPoint:tapPoint]; if (pos != NSNotFound) { + NSLog(@"POS: %zi", pos); NSURL* urlTapped = [self.footerLabel.attributedText URLAtIndex:pos effectiveRange:NULL]; if (urlTapped) [[UIApplication sharedApplication] openURL:urlTapped]; } diff --git a/Example/AttributedStringDemo/ASDViewController.xib b/Example/AttributedStringDemo/ASDViewController.xib index cc98813..0b9429b 100644 --- a/Example/AttributedStringDemo/ASDViewController.xib +++ b/Example/AttributedStringDemo/ASDViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -42,15 +42,14 @@ -