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

Adding Resizing

When the screen is rotated, both the scroll view and form view need to be resized. Then the contentSize property needs to be updated.

You already have code to resize the scroll view. Put breakpoints in keyboardDidShow: and keyboardwillHide: and run the app again. Rotate the screen and you see that each method is called. The system hides and shows the keyboard to set it to the correct size. Those methods also correctly set the size of the scroll area.

The form view is also resized when the screen rotates. This happens when the scroll view changes size and updates the layout for its children. All you need to do is update contentSize from the new form view frame. Add the following line of code at the end of both the keyboardDidShow: ...

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