-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fixes zero size issue when using an attributedTruncationToken. #724
Conversation
… with a dynamic height label.
…attributedTruncationToken. Addresses: TTTAttributedLabel#621 and TTTAttributedLabel#678.
The |
@adonoho are you able to shed any light on the number of lines requirement in |
I look at your patch and see you ignoring the existing |
@adonoho The framesetter that I'm using in |
@adonoho Would replacing
|
This will require CI to pass and new test coverage to be added to be mergable |
Hey @segiddins I did add test coverage for this issue with |
@dillan Each label can have its own |
@adonoho Thanks for your comments. Just to clarify, are you suggesting that Also, to be clear, I'm not trying to add any new behavior, I'm trying to address a regression that was introduced somewhere around 1.13.14. Thanks @adonoho and @segiddins! |
@dillan I'm suggesting that you try to fix the problem on your side of the library, if possible. Your patch, in specific, overrules an existing property with a newly initialized, transient object. I generally view this pattern as a patch and not a root cause solution. If you do not like the property's value, change it. IMO, making a property public is a much better solution than a creating a transient object in a specific method. For the record though, As to the regression since v1.13.14, what changed that introduced this problem? The answer will guide us in finding a root cause solution. |
Thanks @adonoho. I ran a git bisect and here is what I found so far:
|
…itch back to using `-framesetter` in `-sizeThatFits:`
@adonoho I believe that the root cause of the issue is that the attributed string that I've pushed some further changes that may be more appropriate to addressing the root cause by configuring the The question still remains about why the |
@dillan I am happier with your new fix. Thank you for putting up with my objections. Together we make a better library. As to the |
Thanks @adonoho. Setting the number of lines to zero is consistent with the behavior of
https://developer.apple.com/reference/uikit/uilabel/1620539-numberoflines So setting the number of lines to any number other than zero is essentially telling the label that it should be the specified number of lines, where setting 0 means the number of lines should be dynamically calculated. |
@dillan |
@adonoho All very good points. In my testing setting the number of lines to 0, does match the dynamic height behavior I would expect. Further the |
|
…ameSizeForAttributedStringWithConstraints() with the numberOfLines values of 0, 1, and 2.
Current coverage is 77.71% (diff: 100%)
|
@jhersh Correct. It is currently implemented as:
I've updated the unit test to exercise the three possible code paths in the above code:
All three of these possibilities call through to |
@jhersh @adonoho @segiddins Is there anything else you need from me on this? |
@jhersh @adonoho @segiddins just checking to see if there is anything left that I can address for this issue. |
I think it's just awaiting review |
Thanks @jhersh @segiddins! |
We've recently hit this issue also. IS there any way this can get reviews done to be merged? |
I apologize for the delay getting the review done. Being persistent helps. We're all volunteers here. |
No problem. That's why I thought I would ask. Thanks @adonoho! |
Thanks @adonoho! |
Just a heads up, I'm still seeing issues with truncation tokens and single line labels. I'm digging into the issue now to try to figure out what the problem is, but I think it has to do with usage of |
Can we push a new version tag to include this fix? |
Fixes sizeThatFits issue where the size returned was (0, 0) when using an attributedTruncationToken.
Addresses: #621 and #678.
I added a unit test to demonstrate the issue and its resolution. You can run the test from commit [2be9753] to see the size being returned as (0, 0). Re-run the test with commit [b82d006] to see the test pass.