Chapter 6. Controls
Controls are graphical objects used by the user of the application to express their 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.
This chapter starts in Section 6.1 by covering the base class of all controls, UIControl
, and the important target-action mechanism. After that, you learn about several important UI components such as text fields (Section 6.2), sliders (Section 6.3), switches (Section 6.4), buttons (Section 6.5), segmented controls (Section 6.6), page controls (Section 6.7), and date pickers (Section 6.8). We summarize the chapter in Section 6.9.
The Foundation of all Controls
Controls are subclasses of the UIControl
class. The UIControl
class's position in the class hierarchy is shown in Figure 6.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) ...
Get iPhone SDK 3 Programming: Advanced Mobile Development 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.