15
Introduction to Auto Layout

In this chapter, you will return to Homepwner and universalize it so that it will run on an iPad as well as on an iPhone. You will then use the Auto Layout system to ensure that Homepwner’s detail interface appears as you want no matter what type of device it is running on.

Universalizing Homepwner

Currently, Homepwner can be run on the iPad simulator, but it will not look right.

Figure 15.1  An iPhone application running on a simulated iPad

An iPhone application running on a simulated iPad

This is not what you want for your iPad users. You want Homepwner to run natively on the iPad so that it will look like an iPad app. A single application that runs natively on both the iPad and the iPhone is called a universal application.

Reopen your Homepwner project. In the project navigator, select the Homepwner project (the item at the top of the file list). Then select the Homepwner target in the project and targets list and the General tab. This tab presents a convenient interface for editing some of the target’s properties.

Locate the Deployment Info section and change the Devices pop-up from iPhone to Universal (Figure 15.2).

Figure 15.2  Universalizing Homepwner

Universalizing Homepwner

Homepwner is now a universal application. To see the difference, select an iPad simulator from the scheme pop-up menu and then build and run the application. Homepwner looks much better. The table view and its rows are sized appropriately for the iPad screen.

Figure 15.3  A universal application running on the iPad

A universal application running on the iPad

Now add a new item to get to the detail interface. Here the results are not so good:

Figure 15.4  Detail interface does not automatically scale

Detail interface does not automatically scale

The table view interface knew how to resize itself for the iPad sized-screen, but your custom detail interface needs some guidance. You will provide that guidance using Auto Layout.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset