Cover by Vandad Nahavandipoor

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

2.29. Listening and Reacting to Keyboard Notifications

Problem

You are allowing the user to enter some text in your UI, using some component such as a text field or text view that requires the keyboard’s presence. However, when the keyboard pops up on the screen, it obstructs a good half of your UI, rendering it useless. You want to avoid this situation.

Solution

Listen to keyboard notifications and move your UI components up/down or completely reshuffle your components, so that with the keyboard obstructing the screen, what is essential to the user is still visible to him. For more information about the actual notifications sent by the keyboard, please refer to the Discussion section of this recipe.

Discussion

iOS devices do not have a physical keyboard. They have a software keyboard that pops up whenever the user has to enter some text into something like a text field (UITextField, see Recipe 2.19 for more information) or a text view (UITextView, see Recipe 2.20 for more information). On the iPad, the user can even split the keyboard and move it up and down. These are some of the edge cases that you might want to take care of when designing your user interface. You can work with the UI designers in your company (if you have access to such experts) and let them know about the possibility of the user splitting the keyboard on the iPad. They will need to know about that before making the art and creatives. We will discuss that edge case in this recipe.

Let’s have a look at the keyboard ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required