Unable to dismiss app's keyboard even after clicking 'Done' button, and it does not hide when the viewController pop

the bug look like this video:

https://www.youtube.com/shorts/qeUbhJAS0Jo

Welcome to the forum.

It is UIKit app (not SwiftUI ?)

Is it on device or simulator ?

You can add this func in your viewController:

     func textFieldShouldReturn(_ textField: UITextField) -> Bool {
         self.view.endEditing(true)
         return false
     }

Tell if it works, then don't forget to close the thread by marking the correct answer.

Otherwise, could you show the complete attributes inspector for the TextField ? As well as its connections Inspector panel.

Hi @Develop1226, can you share a code sample from your app so that we can take a look at what's happening when your done button is pressed?

-J

@develop1226

I once experienced a similar problem when I defined shouldChangeCharactersIn(), which discarded return keystroke.

Could it be your problem ?

If so, you should add this early in shouldChangeCharactersIn()

          if let char = string.cString(using: String.Encoding.utf8) {
              let isReturn = strcmp(char, "\\r")
              if (isReturn == -82) {
                  backSpace = true
              }
          }

Thanks for your answer. This problem exists in UIKit projects and devices. The keyboard is called up by the WKWebview input box, not the UITextField. Is there any idea to solve this problem? Javascript code like this: input.foucus

I can't relpy with this error.

Hi @Develop1226, I'm not sure why that error is occurring for you. If pasting your code is not working, could you try uploading an attachment instead?

-J

Unable to dismiss app's keyboard even after clicking 'Done' button, and it does not hide when the viewController pop
 
 
Q