OHAttributedLabel doesn't work with autolayout#171
OHAttributedLabel doesn't work with autolayout#171twobitlabs wants to merge 2 commits intoAliSoftware:masterfrom
Conversation
…ntentSize for autolayout
|
We can't do that because this property is only present since iOS6 and OHAttributedLabel is intended specifically to support attributed strings for projects that have to support pre-iOS6 projects (that's why it has been created, at the time UILabel didn't support NSAttributedStrings directly yet). The issue is still open as there is probably a real issue with AutoLayout but I can't accept your pull request as a solution. Maybe better call setNeedsUpdateConstraints or something similar instead to force AutoLayout to recompute the intrisicContentSize when we change the attributedString property, or implement/override intrisicContentSize ourselves to return the |
|
We're mainly using OHAttributedLabel in iOS6+ to render tweets with links, so the user can tap a #hashtag or @mention and go directly to the appropriate URL. I'll take another look at I think the right approach is just to have OHAttributedLabel calculate the appropriate content size. I'll do some more digging. |
|
At least encapsulate the calls to methods introduced in iOS6 like |
If you create an OHAttributedLabel without a frame and position it using autolayout, it has 0 height. This is because when intrinsicContentSize is invoked, attributedText is not set in the UILabel superclass, so the label appears to be empty. Setting the attributedText on the UILabel superclass allows it to calculate the intrinsicContentSize, without any apparent side effects.