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
isNO
, the user's touch events are ignored.highlighted
. This Boolean value controls whether the control is highlighted or not. By default, the value isNO
. When ...
Get iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod touch now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.