Hide the keyboard on iOS in a MAUI app #23640
Unanswered
tpitman
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I thought I would post this here in case anyone else is looking for it. I derived this from some Swift code when I received a warning that the old way of doing it was deprecated.
Here is that post that I found when looking for a solution:
https://stackoverflow.com/questions/57134259/how-to-resolve-keywindow-was-deprecated-in-ios-13-0
Create a new class in the iOS platform folder of your MAUI project. Call it whatever you like.
I called mine KeyboardHelper.
Also create the same named class and put it somewhere that it will be share with all platforms. I just put mine in the project root folder.
You can also create the same class for Android, but that is not the focus of this post because there may be better ways to do it on Android.
I know there are many ways to do this, but decided for my purposes I just made it a partial class so that your common code can see the root partial class without any method and the platform specific code is contained in platform partial classes.
Here is the shared class:
Here is the iOS platform specific class:
I believe this should be compatible from way back in iOS version (at least 11) all the way to 17 and maybe 18.
Enjoy....
Beta Was this translation helpful? Give feedback.
All reactions