How to Interact with an iOS App Through its User Interface

By Rajiv Ramnath

In iOS, application objects take each incoming User Interface (UI) event and route them to their main window. It is good to note that the application monitors its own window’s current status (such as whether it’s in the foreground or the background) to decide whether it should send an event to the main window.

The main window, in turn, keeps track of its sub-windows and their status. Upon receiving an event from the application object, the main window distributes the event to the most appropriate views in its hierarchy.

Some types of views handle events. Most of the time, however, a custom object must be written to handle events. This custom object is typically a view controller object (an instance of the class or a subclass of UIViewController).

View controllers are the key bridging elements of an app. In fact, you can think of them as the skeleton on which apps are built iOS provides several types of view controllers (all subclasses of UIViewController), including the Navigation view controller and the Tab Bar, Page View, and Split View view controllers, as well as popovers. iOS has more view controllers for specific functions, such as for controlling the camera.

Because of the core role of view controllers in an iOS app, we recommend that you start with view controllers when developing an app. The importance of view controllers is also reflected in the sample application templates provided in Xcode. These templates differ only in the kinds of view controllers (and related views) they contain.