Quick and dirty checklist for adding a table view to an existing view controller:
- Embed existing view controller in a NavigationController
- Drag a UITableView object into the view controller in the storyboard
- Make the UITableView the same width and height as the view controller and set the constraints to all four sides with no margins
- Create an outlet and connection for the tableView in the view controller class
- Add
UITableViewDataSource
andUITableViewDelegate
to the class declaration. Your class should look something like thisimport UIKit class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() } }
- Select the table view, open the connections inspector and connect the table view’s
dataSource
anddelegate
methods to the View Controller object. - If you’re not using static cells, open the attributes inspector and set the number of Prototype Cells to 1
Thank you so much for this!