Thursday, 4 October 2018

Swift: MaterialComponents TextFields Unexpected Placeholder Behavior when clicking fast

I have open the issue at MaterialComponents on Github already but seem like no answer yet. The problem is when I click the textfield to be active then I click outside, it was working fine but when I repeat doing that, the placeholder for the textfield will be always on the top

Here is the problem as an image

When textfield didload: enter image description here

When textfield active: enter image description here

When we repeat click on textfield then click outside again it will look like this enter image description here

Here is the code:

@IBOutlet weak var textfieldFloating: MDCTextField!
let tf = MDCTextInputControllerOutlined()

override func viewDidLoad() {
        super.viewDidLoad()
        textfieldFloating.leftView = UIImageView(image: UIImage(named: "ic_lock_outline_white_18pt"))
        textfieldFloating.leftViewMode = .always
        textfieldFloating.placeholder = "Placeholder"
        tf.textInput = textfieldFloating
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.view.endEditing(true)
    }



from Swift: MaterialComponents TextFields Unexpected Placeholder Behavior when clicking fast

1 comment: