Created
September 1, 2011 13:34
-
-
Save stigi/1186172 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/OHAttributedLabelTest/RootViewController.m b/OHAttributedLabelTest/RootViewController.m | |
| index 13ca5ef..547d928 100644 | |
| --- a/OHAttributedLabelTest/RootViewController.m | |
| +++ b/OHAttributedLabelTest/RootViewController.m | |
| @@ -86,6 +86,7 @@ | |
| NSString *baseString = [self.wordList objectAtIndex:indexPath.row]; | |
| NSMutableAttributedString *attributedString = [NSMutableAttributedString attributedStringWithString:baseString]; | |
| + [(OHAttributedLabel*)[cell viewWithTag:1337] removeAllCustomLinks]; | |
| [(OHAttributedLabel*)[cell viewWithTag:1337] setAttributedText:attributedString]; | |
| NSString *urlString = [NSString stringWithFormat:@"user://%@", baseString]; | |
| [(OHAttributedLabel*)[cell viewWithTag:1337] addCustomLink:[NSURL URLWithString:urlString] inRange:[baseString rangeOfString:baseString]]; |
@stigi just to let you know that I just commited a new version on github that fixes this issue: all custom links are removed each time you change the text or attributedText of the OHAttributedLabel (as they don't have any sense any more anyway).
Thanks for the help!
Author
great :)
thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@RickiG, @stigi
What a coincidence, actually for my own app FoodReporter I did a correction in OHAttributedLabel's setAttributedText: method no later than this morning, so that each time the text is modified, the custom links are removed. I guess this correction makes sense as if you modify the attributedText, the custom links you previously set with given ranges don't make sense anymore.
I planned to commit this simple correction this weekend (or even maybe tomorrow), didn't realize our problems had the same origin ;)
I'll keep you posted as soon as I commited my correction, so that you would not even need to take care of removing custom links you may have previously set!
Note: In the future I guess it would be much more logical that the NSAttributedString itself keep track of the custom links (by adding an attribute to a range of the AttributedString itself and not add the custom link on OHAttributedLabel), but I guess then the whole link detection code and rendering links in blue, underlined whould then need to be refactored... and I don't think I'll have time for this kind of refactoring soon :-/