Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Implementing a Table View in Your iOS App

The functionality in the DestinationController is in the Table view. You’ve probably worked with Table views before — but those used static cells. Now it’s time to branch out on your own and understand what is happening behind the scenes, as it were.

It’s a good thing to know how Table views work, because Table views are front and center in several applications that come with the iOS devices out of the box; they play a major role in many of the more complex applications that you can download from the App Store. (Obvious examples: Almost all the views in the Mail, Music, and Contacts applications are Table views.)

Table views take on such a significant role because, in addition to displaying data, they can also serve as a way to navigate a hierarchy.

If you take a look at an application such as Mail or Music, you find that Table views present a scrollable list of items (or rows or entries — you can use all three terms interchangeably) that may be divided into sections.

A row can display text or images, so when you select a row, you may be presented with another Table view or with some other view that may display a web page or even controls such as buttons and Text fields.

It’s worth noting that iOS Table views only provide a single column of data—not the two-dimensional tables that you might build in a Microsoft Excel spreadsheet. The Macintosh OS X frameworks do provide a multi-column NSTableView class, but the IOS UITableView only supports a single column. There are open-source grid views available for iOS, such as the DTGridView found on GitHub.

To kick off the Table view creation process, you first need to decide what you want to have happen when the user selects a particular row in the Table view of your app. As you saw with static cells, you can have virtually anything happen. You can display a Web view as you do in Weather or even display another Table view.

In this case, however, the Destination View controller will be dismissed, and the user will find herself in the Main view, ready to make another selection.

A Table view is an instance of the class UITableView, where each visible row of the table uses a UITableViewCell to draw its contents. Think of a Table view as the object that creates and manages the table structure, and the Table View cell as being responsible for displaying the content of a single row of the table.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!