Skip to content
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

Unexpected behaviour with UILabel.numberOfLines = 0 #41

Closed
Mackarous opened this issue Oct 2, 2015 · 7 comments
Closed

Unexpected behaviour with UILabel.numberOfLines = 0 #41

Mackarous opened this issue Oct 2, 2015 · 7 comments

Comments

@Mackarous
Copy link

I have a TZStackView hierarchy with a bunch of UILabels in it. They have numberOfLines = 0. The problem is that if I attempt the same code with UIStackView on iOS 9, or TZStackView on iOS 9, the UILabels wrap. However with TZStackView on iOS 8.x, the UILabel is ellipsized. Any thoughts on this?

@fabb
Copy link

fabb commented Oct 5, 2015

Have you tried something like that?

class MultilineLabelThatWorks : UILabel {
  override func layoutSubviews() {
    super.layoutSubviews()
    preferredMaxLayoutWidth = bounds.width
    super.layoutSubviews()
  }
}

@Mackarous
Copy link
Author

@fabb I am doing that as a workaround (without subclassing, I think that's overkill), but the issue is that on iOS 9 with a UIStackView, setting the preferredMaxLayoutWidth is not necessary

@fabb
Copy link

fabb commented Oct 6, 2015

No issue, just juse an #available macro.

@Mackarous
Copy link
Author

Well the issue is it is no longer a drop in replacement, but I guess it'll have to do.

@tomvanzummeren
Copy link
Owner

This is strange. Can you try to compare the constraints generated on UIStackView and on TZStackView as well as the constraints added to your UILabels? There should be a difference, and if there is: this is a bug and I will try to fix it.

@fabb
Copy link

fabb commented Oct 7, 2015

Hm, you're right, preferredMaxLayoutWidth = 0 should be supported since iOS 8. For iOS 7 the workaround would be necessary.

@Mackarous
Copy link
Author

Going to close this one out for inactivity

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