Web Designer’s Guide to iOS Apps: universal app sample code

On pages 133-138, I provided an example of a universal app — a video player app that runs full-screen on both small iOS (iPhone and iPod touch) and large (iPad) devices, from the same app installation. But because this example uses NKVideoPlayer, much of the heavylifting is done for us already because in this case the native iOS video player interface automatically resizes to the device for us.
So what about when we are using an interface element that has a size specification, such as NKTableView?

In this case, we need to employ NKGetDeviceType to first determine on which device the app is running, and then have the screen display the appropriately-sized table view. If the device type is not checked, the app will indeed still run full screen on both devices… but on the iPad, the table view will be sized small for the iPhone and therefore surrounded by a large sea of white background. Not what you intended, I’m sure!
A reader (James Rhodes) and I worked together on some sample code for such a solution, and I’ve posted a universal app example download to iosapps.tumblr.com. If you’re interested in seeing how a tableview adapts to iPhone and iPad screen sizes, download and check it out on Simulator.
Related tips — make sure your project Build settings include:
* Base SDK = Latest iOS
* Targeted device family = iPhone / iPad
* iOS deployment target = iOS 3.2 (or later)
Finally, remember that to test on multiple devices, you’ll need to obtain separate provisioning certificates for each.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s