WHAT YOU WILL LEARN IN THIS CHAPTER
How to create a Window-based Application and manually add a View Controller and a View window to it
How to create views dynamically during runtime
How to wire up events of views with event handlers via code
How to switch to another view during runtime
How to animate the switching of views
Until this point, you have been dealing with single view applications; that is, applications with a single View Controller. The previous chapters have all been using the View-based Application template available in the iPhone SDK because it is the simplest way to get started in iPhone programming. When you create a View-based application, there is by default one View Controller (named
>ViewController by the iPhone SDK). In real-life applications, you often need more than one View Controller, with each controlling a different view displaying different information. A good example of a multiview application is the Weather application shipped with the iPhone. The main view shows the weather of a region you have selected, and you can swipe the screen to view the weather of other locations. You can also press the i icon to flip to another view and add locations.
This chapter teaches you 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.