Game Development Reference
In-Depth Information
Graphically Designing Your UI in a Universal Way
When building an app for both the iPhone and iPad, we must consider the differences in screen size
for each device. Because the two devices do not share an aspect ratio, we should really create a
layout for each device. In this section, we will cover how to create a layout for each device type, as
well as create classes that will be used depending on which device the application is running on.
Xcode provides a convenient and powerful tool for laying out the graphical elements of an application.
Historically, that was done with the application Interface Builder, which was a stand-alone application.
In recent versions of Xcode, the functionality of Interface Builder has been rolled into Xcode to provide
a seamless development environment. Although Interface Builder is no longer its own application,
I will continue to use the term to refer to the UI layout tools within Xcode. This will help us distinguish
Note When searching for help on the Internet regarding Interface Builder, keep in mind that XIB files
used to be called NIB files. Much of the information available uses this old term, but it is still valid. The
same is true of Interface Builder; articles on the old version still give valuable insight into the new version.
A First Look at Interface Builder
Under the iPhone group in the Project Explorer is a file called ViewController_iPhone.xib . This file
contains the starting visual components used in this project when the application is running on an
iPhone. Similarly, there is a file called ViewController_iPad.xib found under the iPad group, which
is used when the application is running on an iPad. Let's focus on the iPhone version for now to see
what this file is and how it works. Click ViewController_iPhone.xib and you should see something
like Figure 2-12 .
 
Search WWH ::




Custom Search