3
Views and the View Hierarchy

Over the next five chapters, you are going to build an application named WorldTrotter. When it is complete, this app will convert values between degrees Fahrenheit and degrees Celsius. In this chapter, you will learn about views and the view hierarchy through creating WorldTrotter’s UI. At the end of this chapter, your app will look like Figure 3.1.

Figure 3.1  WorldTrotter

Screenshot of the Prototype of the WorldTrotter user interface. The interface screen reads 212 degrees Fahrenheit is really 100 degrees Celsius.

Let’s start with a little bit of the theory behind views and the view hierarchy.

View Basics

Recall from Chapter 1 that views are objects that are visible to the user, like buttons, text fields, and sliders. View objects make up an application’s UI. A view:

  • is an instance of UIView or one of its subclasses

  • knows how to draw itself

  • can handle events, like touches

  • exists within a hierarchy of views whose root is the application’s window

Let’s look at the view hierarchy in greater detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset