O'Reilly logo

Beginning iPhone® SDK Programming with Objective-C® by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. View Controllers

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 <project_name>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.

CREATING A WINDOW-BASED ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required