O'Reilly logo

iOS 8 Swift Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Table and Collection Views

6.0. Introduction

A table view is simply a scrolling view that is separated into sections, each of which is further separated into rows. Each row is an instance of the UITableViewCell class, and you can create custom table view rows by subclassing this class.

Using table views is an ideal way to present a list of items to users. You can embed images, text, and other objects into your table view cells; you can customize their height, shape, grouping, and much more. The simplicity of the structure of table views is what makes them highly customizable.

A table view can be fed with data using a table view data source, and you can receive various events and control the physical appearance of table views using a table view delegate object. These are defined, respectively, in the UITableViewDataSource and UITableViewDelegate protocols.

Although an instance of UITableView subclasses UIScrollView, table views can only scroll vertically. This is more a feature than a limitation. In this chapter, we will discuss the different ways of creating, managing, and customizing table views.

Table views are great. They really are. However, they are very rigid in that they always render their content vertically. They aren’t grids and weren’t meant to act like grids. However, as a programmer, you may find yourself in a situation where you want to draw a grid-like component with columns and rows, and put different types of UI objects in each one, or make each one interactive. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required