|
Another beginner's question! I use this code, which I picked up from someone helpful (perhaps here), so that a tap anywhere dismisses the keyboard being shown:
It works very nicely. I'd like to be able to call a function when the keyboard is dismissed, but my knowledge of iOS outside SwiftUI is pretty much zero. Can I add a function call to this code somehow? |
|
You have a Here is an example of what you can add:
You will need to change the action parameter to |
|
Thanks - I'd tried changing the #selector to a function, but no matter how I define the function, I get a crash immediately:
-[UIWindow dismissKeyboard:]: unrecognized selector sent to instance 0x7fd716909110 I've tried various declarations of dismissKeyboard, but the result is always the same. Jeremy |
|
What your error message is saying is that the To fix this, make sure the target you pass into the tap gesture has the
|
|
This reminds me of learning how to write for MacOS in the 1980s, when it was said that in order to understand any one of the five volumes of Inside Mac, one had first to have read and understood the other four. I'm afraid I'm going to parade my ignorance again: how do I do what you suggest? At present, with the code as it stands,
and with |
|
Maybe this will help:
I've tested this and it seems to work. Every time I tap on the screen, the |
|
It does work, and it is exactly what I was looking for. Thanks very much. I've learned something as well as having a problem fixed. Jeremy |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.