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

floating labels shown on textfields with no text #7

Open
ssavic opened this issue Oct 1, 2015 · 1 comment
Open

floating labels shown on textfields with no text #7

ssavic opened this issue Oct 1, 2015 · 1 comment

Comments

@ssavic
Copy link

ssavic commented Oct 1, 2015

If you add a floating label text field to a tableview cell and add about 20 or so of them, so that they are off the screen. when tableview reuses cells, it still shows floating label even for the textfields that have no text.

I've fixed the issue, but i'm having issue make a pull request.
This is where the issue is:

override public func layoutSubviews() {
super.layoutSubviews()
if (isFirstResponder() && !hasText()) {
hideFloatingLabel()
} else if(hasText()) {
showFloatingLabelWithAnimation(true)
}
}

just change it to:

override public func layoutSubviews() {
super.layoutSubviews()
if ((isFirstResponder() && !hasText()) || !hasText()) {
hideFloatingLabel()
} else if(hasText()) {
showFloatingLabelWithAnimation(true)
}
}

Sasa

@misuqian
Copy link

I change the code and have no effect. below is my changes and it work very well

override public func hasText() ->Bool {
return self.text! != ""
}

override public func layoutSubviews() {
super.layoutSubviews()
if (!isFirstResponder() && !hasText()) {
hideFloatingLabel()
} else {
showFloatingLabelWithAnimation(true)
}
}

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

2 participants