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

Posted on Apr 28, 2025 8:15 AM

Reply
5 replies

Apr 28, 2025 9:33 AM in response to guan_

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(_:)


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Unable to dismiss app's keyboard even after clicking 'Done' button

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.