Fixed that text got updated during view update

This commit is contained in:
dankito 2020-07-29 14:46:22 +02:00
parent 5f97a21965
commit 2e62a23e63
1 changed files with 3 additions and 1 deletions

View File

@ -100,7 +100,9 @@ struct UIKitTextField: UIViewRepresentable {
} }
func textFieldDidChangeSelection(_ textField: UITextField) { func textFieldDidChangeSelection(_ textField: UITextField) {
text = textField.text ?? "" DispatchQueue.main.async { // to not update state during view update
self.text = textField.text ?? ""
}
} }
func textFieldShouldReturn(_ textField: UITextField) -> Bool { func textFieldShouldReturn(_ textField: UITextField) -> Bool {