Skip to content

setAttributedText not reseting links #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Arrnas opened this issue Mar 26, 2015 · 4 comments
Closed

setAttributedText not reseting links #513

Arrnas opened this issue Mar 26, 2015 · 4 comments

Comments

@Arrnas
Copy link

Arrnas commented Mar 26, 2015

I seem to have the same issue as #274. With the current version, using the label inside a tableview cell setAttributedText seems to reset the styling of the text since the text doesn't have link stylings, but the range is still clickable with the old link.
I tried adding

self.linkModels = [NSArray array];

inside setAttributedString and it seems to remove the old links, but when a correct link is set it becomes unclickable after one click or long press.

@Arrnas
Copy link
Author

Arrnas commented Mar 26, 2015

I noticed that setText is able to take attributed strings. Using setText seems to resolve the problem of old links not being removed but introduces a different problem - it detects phone numbers in my attributed string despite not doing anything to enable this, is it possible to disable the checking? NSTextCheckingType doesn't seem to have a none option for enabledTextCheckingTypes.
It seems that i'm the one setting the link attribute on the attributed string, everything seems to be working as expected with setText.

@Arrnas Arrnas closed this as completed Mar 26, 2015
@jhersh
Copy link
Contributor

jhersh commented Mar 26, 2015

Also see this note in TTTAttributedLabel.h on the attributedText property:

@warning Do not set this property directly. Instead, set @c text to an @c NSAttributedString.

As you've noted, you should instead call setText: with either a regular or attributed string.

@Arrnas
Copy link
Author

Arrnas commented Mar 29, 2015

I was already using attributed strings when i decided to drop in TTTAttributedLabel so I didn't see any warnings. I don't know how often setAttributedText is used but maybe it would be useful to add a deprecated warning on it.
Anyways thanks for the reply and your work on this repo, it saved me a lot of time when i had to make my labels work with links.

@chikuba
Copy link

chikuba commented Jul 6, 2015

I just had the same issue, so yeah, a warning would be nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants