O'Reilly logo

iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod touch by Maher Ali

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 5. Controls

Controls are graphical objects used by the user of the application to express his/her objective. For example, a slider control can be used by the user as a way to fine tune a specific value. A switch control, on the other hand, can be used to turn on/off an option. In this chapter, we present several important graphical controls that can be used in building attractive iPhone applications.

We will cover the main graphical controls available, and their usage. Before we begin talking about specialized controls, let's understand the base class for all controls, UIControl, and the important target-action mechanism.

The Foundation of All Controls

Controls are subclasses of the UIControl class. The UIControl class position in the class hierarchy is shown in Fig. 5.1. The common behavior of controls is captured by this class. Therefore, understanding this class is essential to using its concrete subclasses such as UITextField, UISlider, UIDatePicker, etc.

UIControl attributes

As a superclass of controls, the UIControl class has several shared attributes that can be configured using accessor methods. These attributes include:

  • enabled. This is a Boolean attribute that represents whether the control is enabled or not. The property is defined as:

    @property(nonatomic, getter=isEnabled) BOOL enabled

    If the value for enabled is NO, the user's touch events are ignored.

  • highlighted. This Boolean value controls whether the control is highlighted or not. By default, the value is NO. When ...

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