iOS 7 TableView like in Settings App on iPad
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
With the release of iOS 7, Apple reimagined the appearance and functionality of its mobile operating system, employing a flat design and adding many nuanced features. Amongst these changes was the re-design of the UITableView
, a common UIKit component used for displaying lists of information. The TableView
is a particularly prevalent component in apps that require structured data presentation, such as Apple's own Settings app on the iPad. This article delves into the intricacies of using a TableView
in iOS, especially as seen in the Settings app on the iPad.
Anatomy of a TableView
A UITableView
is essentially a vertically scrolling list that can be customized to fit the requirements of the app. For example, the Settings app uses it to present various configurable options in a hierarchical manner, capitalizing on the simplicity and intuitiveness of the TableView
. Here are some of the core aspects:
- Sections and Rows:
UITableViewis divided into sections, with each section potentially having numerous rows. In the Settings app, these sections are used to categorize related settings, such as "Wi-Fi" and "Bluetooth" grouped under the "Network" section. - Cells: Each row is represented by a
UITableViewCell. These cells can be customized extensively, both in terms of layout and interactivity. For instance, in the Settings app, cells are often a mix of labels and switches or buttons. - Header and Footer Views: Sections can have optional header and footer views. These are typically used in the Settings app for providing context or explanations about groups of settings.
Implementing a TableView
Creating and configuring a UITableView
involves several key steps and structures in the UIKit framework:
1. TableView DataSource & Delegate
The UITableViewDataSource
protocol is essential for feeding data to the table view. It requires the implementation of several methods, the most basic of which are:
tableView(_:numberOfRowsInSection:): Returns the number of rows in a given section.tableView(_:cellForRowAt:): Configures and returns the cell for a specified row and section.
Meanwhile, the UITableViewDelegate
protocol adds behavior customization, such as responding to row selections.
Related reading
- iOS 7 TextKit - How to insert images inline with text?
- iOS 7 Translucent Modal View Controller
- iOS 7 UIBarButton back button arrow color
- iOS 7 UITableView shows under status bar
- iOS 8.1 Simulator Localization broken NSLocalizedString
- iOS 8 removed minimal-ui viewport property, are there other soft fullscreen solutions?
- iOS 8 UITableView separator inset 0 not working
- iOS 8 UITableView separator inset 0 not working
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.