New to Swift.
When a user clicks on a text field to begin typing, is there a way to disable all user interaction other than typing into that text field? I want it so that the user is unable to click outside the text field, and should press the return key to dismiss keyboard, where user interaction is enabled again (I have the dismiss keyboard part set up).
I know that the isUserInteractionEnabled function can stop all interaction, but I still want the user to be able to interact with the keyboard.
Thanks
The behavior you describe is can be accomplished by manipulating the Boolean
isEnabled
value if UI elements. There are a couple of steps to make this smooth and user friendly.Just good practice, and not required for this example, but I like to make extension of the MyViewController, to subscribe/unsubscribe to keyboard notifications and so on in it, like so:
Next, in MyViewController, I set the keyboard to
resignToFirstResponder()
when the return key is tapped, and I make sure to set myUITextFieldDelegates
.Note that last function!!! Use it to enable/disable other elements while the keyboard is active, as I've shown.
That should get you where you need to go :)