O'Reilly logo

Beginning iPhone® SDK Programming with Objective-C® by Wei-Meng Lee

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

Chapter 6. Screen Rotations

WHAT YOU WILL LEARN IN THIS CHAPTER

  • How to support the four different types of screen orientations

  • The various events that are fired when a device rotates

  • How to reposition the views on a View when the orientation of a device changes

  • How to change the screen rotation dynamically during runtime

  • How to set the orientation of your application before it is loaded

With the Hello World! application in Chapter 2, you saw how your iPhone application can be written so that it supports viewing in either the portrait or landscape mode. This chapter dives deeper into the topic of screen orientation. In particular, you will learn how to manage the orientation of your application when the device is rotated. You will also learn how to reposition your views when the device is rotated so that your application can take advantage of the change in screen dimensions.

RESPONDING TO DEVICE ROTATIONS

One of the features that modern mobile devices support is the ability to detect the current orientation — portrait or landscape — of the device. An application can take advantage of this ability to readjust the device's screen to maximize the use of the new orientation. A good example is Safari on the iPhone. When you rotate the device to landscape orientation, Safari automatically rotates its view so that you have a wider screen to view the content of the page (see Figure 6-1).

Figure 6-1

Figure 6.1. Figure ...

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