Unable to dismiss app's keyboard even after clicking 'Done' button
keyboard can't even hide with this code
[[UIApplication sharedApplication].keyWindow endEditing:YES];
[Re-Titled by Moderator]
iPhone 14 Plus, iOS 18
keyboard can't even hide with this code
[[UIApplication sharedApplication].keyWindow endEditing:YES];
[Re-Titled by Moderator]
iPhone 14 Plus, iOS 18
The provided code will no longer remove the keyboard when Done is pressed. You have another issue going on and will need to resignFirstResponder based on the delegate of the UITextField. The lifecycle of views has changed long ago and code found on the internet will no longer work when targeting newer iOS versions.
I still suggest you use the provided link to post in the Apple Developer forum and include a snippet of your code there for any delegate methods you have for the UITextView. If you have any logic in textViewShouldEndEnditing, then returning NO will leave the keyboard on the screen. By default it is not needed and will return YES when it has received resignFirstResponder by pressing the Done button..
https://developer.apple.com/documentation/uikit/uitextviewdelegate/textviewshouldendediting(_:)
Depending on what iOS version you are targeting keyWindow may have been deprecated. The keyWindow is a property UIWindowScene and you are attempting to use it on a Singleton of the UIApplication.
You may get more responsive help posting over at the Apple Developer forums for any programming related issues.
the bug look like this video:
I did not actively use keyWindow to hide the keyboard. In the current bug, clicking the Done button on the keyboard does not hide it, and it does not hide when the viewController pop, like this https://www.youtube.com/shorts/qeUbhJAS0Jo.
Thanks for your suggestion, I have posted in Apple Developer forum. My textView is input in WKWebView and there is no logic of textViewShouldEndIting. Unable to dismiss app's keyboard e… | Apple Developer Forums
Unable to dismiss app's keyboard even after clicking 'Done' button