Chapter 4. View Controllers

WHAT YOU WILL LEARN IN THIS CHAPTER

  • Understanding the structure of a View-based Application project

  • How to create a Window-based Application project and manually add a View Controller and a View window to it

  • Creating views dynamically during runtime

  • Wiring up events of views with event handlers via code

  • How to switch to another view during runtime

  • How to animate the switching of views

  • How to create a Split View-based application

  • How to create a Tab Bar application

So far you've dealt only with single-view applications — that is, applications with a single View Controller. The previous chapters all use the View-based Application template available in the iPhone SDK because it is the simplest way to get started with iPhone programming. When you create a View-based Application project, there is one View Controller (named <project_name>ViewController by the iPhone SDK) by default.

In real-life applications, you often need more than one View Controller, with each controlling a different view displaying different information. This chapter explains the various types of projects you can create for your iPhone and iPad and how each utilizes a different type of View Controller. You will also learn how to create multiple views in your application and then programmatically switch among them during runtime. In addition, you learn how to animate the switching of views using the built-in animation methods available in the iPhone SDK.

The View-Based Application Template

When you ...

Get Beginning iOS 4 Application Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.