Programmatic Controls

Now let’s update the segmented control to change the map type when the user taps on a segment.

A UISegmentedControl is a subclass of UIControl. You have worked with another UIControl subclass in Chapter 1, the UIButton class. Controls are responsible for calling methods on their target in response to some event.

Control events are of type UIControlEvents. Here are a few of the common control events that you will use:

UIControlEvents.TouchDown

A touch down on the control.

UIControlEvents.TouchUpInside

A touch down followed by a touch up while still within the bounds of the control.

UIControlEvents.ValueChanged

A touch that causes the value of the control to change.

UIControlEvents.EditingChanged ...

Get iOS Programming: The Big Nerd Ranch Guide 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.