NIAttributedLabel #358

merged 3 commits into from Mar 26, 2013


None yet
2 participants

migrant commented Mar 8, 2013

Adding links after images, the AttributedLabel fall to detect link
touch and give the correct highlight rect

migrant added some commits Mar 8, 2013

migrant closed this Mar 8, 2013

migrant reopened this Mar 8, 2013

@jverkoey jverkoey commented on the diff Mar 14, 2013

@@ -788,9 +788,20 @@ - (NSTextCheckingResult *)linkAtPoint:(CGPoint)point {
CGPoint relativePoint = CGPointMake(point.x-CGRectGetMinX(rect),
CFIndex idx = CTLineGetStringIndexForPosition(line, relativePoint);
- foundLink = [self linkAtIndex:idx];
+ NSUInteger offset = 0;
+ for (NIAttributedLabelImage *labelImage in self.images) {
+ if (labelImage.index < idx) {
+ offset++;

jverkoey Mar 14, 2013


Can you add a comment explaining what this is doing?


migrant Mar 14, 2013


If I insert a image at index m then after it add a link at index n (i.e n > m), after drawing text the link location is added by 1 in attributed string because NIAttributedLabel insert a 0xFFFC into attributed string for every image. In this case, the link location is n+1 in attributed string but is still n in the NSArray detectedlinkLocations or explicitLinkLocations.
When touching a character before which there are images, CTLineGetStringIndexForPosition(line, relativePoint) returns the actual index but I must provide a original index for [self linkAtIndex:idx] to determine whether I touch a link.So I must know how many images before and calcute the correct index.

@jverkoey jverkoey added a commit that referenced this pull request Mar 26, 2013

@jverkoey jverkoey Merge pull request #358 from migrant/master

@jverkoey jverkoey merged commit 16e0ecc into jverkoey:master Mar 26, 2013


jverkoey commented Mar 26, 2013


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment