Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Beginning iOS5 Development.pdf
Скачиваний:
7
Добавлен:
09.05.2015
Размер:
15.6 Mб
Скачать

280

CHAPTER 9: Navigation Controllers and Table Views

Nav, a Hierarchical Application in Six Parts

The application we’re about to build will show you how to do most of the common tasks associated with displaying a hierarchy of data. When the application launches, you’ll be presented with a list of options (see Figure 9–2).

Figure 9–2. This chapter application’s top-level view. Note the accessory icons on the right side of the view. This particular type of accessory icon is called a disclosure indicator. It tells the user that touching that row drills down to another table view.

Each of the rows in this top-level view represents a different view controller that will be pushed onto the navigation controller’s stack when that row is selected. The icons on the right side of each row are called accessory icons. This particular accessory icon (the gray arrow) is called a disclosure indicator, because it lets the user know that touching that row drills down to another table view.

Meet the Subcontrollers

Before we start building the Nav application, let’s take a quick look at each of the views displayed by our six subcontrollers.

www.it-ebooks.info

CHAPTER 9: Navigation Controllers and Table Views

281

The Disclosure Button View

Touching the first row of the table shown in Figure 9–2 will bring up the child view shown in Figure 9–3.

Figure 9–3. The first of the Nav application’s six subcontrollers implements a table in which each row contains a detail disclosure button.

The accessory icon to the right of each row in Figure 9–3 is a bit different. Each of these icons is known as a detail disclosure button. Tapping the detail disclosure button should allow the user to view, and perhaps edit, more detailed information about the current row.

Unlike the disclosure indicator, the detail disclosure button is not just an icon—it’s a control that the user can tap. This means that you can have two different options available for a given row: one action triggered when the user selects the row and another action triggered when the user taps the disclosure button.

A good example of the proper use of the detail disclosure button is found in the iPhone’s Phone application. Selecting a person’s row from the Favorites tab places a call to the person whose row you touched, but selecting the disclosure button next to a name takes you to detailed contact information. The YouTube application offers another great example. Selecting a row plays a video, but tapping the detail disclosure button takes

www.it-ebooks.info

282

CHAPTER 9: Navigation Controllers and Table Views

you to more detailed information about the video. In the Contacts application, the list of contacts does not feature detail disclosure buttons, even though selecting a row does take you to a detail view. Since there is only one option available for each row in the Contacts application, no accessory icon is displayed.

Here’s a recap of when to use disclosure indicators and detail disclosure buttons:

If you want to offer a single choice for a row tap, don’t use an accessory icon if a row tap will only lead to a more detailed view of that row.

Mark the row with a disclosure indicator (gray arrow) if a row tap will lead to a new view (not a detail view).

If you want to offer two choices for a row, mark the row with a detail disclosure button. This allows the user to tap on the row for a new view or the disclosure button for more details.

The Checklist View

The second of our application’s six subcontrollers is shown in Figure 9–4. This is the view that appears when you select Check One in Figure 9–2.

Figure 9–4. The second of the Nav application’s six subcontrollers allows you to select one row from many.

www.it-ebooks.info

CHAPTER 9: Navigation Controllers and Table Views

283

This view comes in handy when you want to present a list from which only one item can be selected. This approach is to iOS what radio buttons are to Mac OS X. These lists use a check mark to mark the currently selected row.

The Rows Control View

The third of our application’s six subcontrollers is shown in Figure 9–5. This view features a tappable button in each row’s accessory view. The accessory view is the farright part of the table view cell that usually holds the accessory icon, but it can be used for other things. When we get to this part of our application, you’ll see how to create controls in the accessory view.

Figure 9–5. The third of the Nav application’s six subcontrollers adds a button to the accessory view of each table view cell.

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]