O'Reilly logo

Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming by Erica Sadun, Rod Strougo, Maurice Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Resizing for the Keyboard

When the keyboard comes up, it might cover one or more of the input fields. A scroll view lets you move the fields into view so the user can see where he or she can input text. All you have to do is resize the scroll view so it is above the keyboard. The scroll view becomes smaller, but the content size does not change and the user can scroll the form view, and therefore, the fields.

When the keyboard opens and closes, iOS uses the built-in NSNotificationCenter to send events. You add code to listen for the correct events and change the size of the scroll view as needed. Doing this takes three steps:

1. Add methods responding to keyboard open-and-close events.

2. Register for keyboard open-and-close notifications when ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required