Keyboard dismiss very buggy on tableview interactive
I launched your application with iOS 12 and it works correctly.
This solution may help you with iOS 13.
1) Add the observer in viewDidLoad()
override func viewDidLoad() {
...
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
2) Add function getKeyboardWindow()
private func getKeyboardWindow() -> UIWindow? {
for window in UIApplication.shared.windows {
if (NSStringFromClass(type(of: window).self) == "UIRemoteKeyboardWindow") {
return window
}
}
return nil
}
3) Add function keyboardWillHide(notification:)
@objc private func keyboardWillHide(notification: Notification) {
guard let keyboardWindow: UIWindow = getKeyboardWindow() else { return }
let screenWidth: CGFloat = UIScreen.main.bounds.width
let screenHeight: CGFloat = UIScreen.main.bounds.height
keyboardWindow.frame = CGRect(x: 0, y: 50, width: screenWidth, height: screenHeight)
}
P.S. However, I don't like to fix issues this way.
But in this case, I don't know a more elegant solution.
doe,
What you are doing is right, I don't see that as an issue, even contacts app have the same feature like yours (i.e text field in table view). Contact app also behaves the same way
Find the comparison screen recording of contact app and yours,
.
If you still want to fix it, I would suggest to remove auto-correction, If your requirement allows.
textView.autocorrectionType = .no