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

TextField Detail Label not Layed-Out correctly with Left-Image #1053

Closed
cody1024d opened this issue Apr 3, 2018 · 4 comments
Closed

TextField Detail Label not Layed-Out correctly with Left-Image #1053

cody1024d opened this issue Apr 3, 2018 · 4 comments

Comments

@cody1024d
Copy link

So, I ended up tracking down this issue after my app is not displaying the entirety of the detail label when there is a left image. Specifically, I believe there is an issue in the following code:

    /// Layout the detailLabel.
    func layoutDetailLabel() {
        let c = dividerContentEdgeInsets
        detailLabel.frame.size.height = detailLabel.sizeThatFits(CGSize(width: bounds.width, height: .greatestFiniteMagnitude)).height
        detailLabel.frame.origin.x = c.left
        detailLabel.frame.origin.y = bounds.height + detailVerticalOffset
        detailLabel.frame.size.width = bounds.width - c.left - c.right
    }

The issue is the following line, specifically:

let c = dividerContentEdgeInsets
        detailLabel.frame.size.height = detailLabel.sizeThatFits(CGSize(width: bounds.width, height: .greatestFiniteMagnitude)).height

We're taking the bounds of the entirety of the textfield (which includes the left image's width) and using that to compute the height of the detail label. Unfortunately, this is incorrect, because the detail label does not go across the full width of the view, it follows the width of the actual textfield only.

So in my case, I'm getting an incorrect height, because my detail text COULD fit in one line (height of 16) if the detail label stretched the whole width, HOWEVER, since this isn't the case, I really need a height of 32. I believe the correct fix is to use detailLabel.frame.width there, as that's the actual width of the label that we're sizing.

I've made the changes locally, so I've had to essentially detatch myself from updates for this class until this is fixed :(

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Apr 3, 2018

Hey! Thank you for finding this issue. I'll look into this today and make a release :)

@daniel-jonathan
Copy link
Member

I haven't finished my investigation on this. Will update you shortly. Thank you!

@OrkhanAlikhanov
Copy link
Contributor

OrkhanAlikhanov commented Jun 2, 2018

Hey @DanielDahan, this is the issue we discussed recently. It should've been solved in #1082

@cody1024d, you are right it should be detailLabel.frame.width not bounds.width

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Jun 6, 2018

Excellent, so I will close this. Thank you!

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

No branches or pull requests

3 participants