Beginning iOS Programming with Swift and UIKit (iOS 15) by Simon Ng
Author:Simon Ng
Language: eng
Format: epub
Publisher: GitBook
Now open RestaurantDetailViewController.swift and update the total number of cells:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 3 }
Also, update the tableView(_:cellForRowAt:) method like this:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { switch indexPath.row { case 0: let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: RestaurantDetailTextCell.self), for: indexPath) as! RestaurantDetailTextCell cell.descriptionLabel.text = restaurant.description return cell case 1: let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: RestaurantDetailTwoColumnCell.self), for: indexPath) as! RestaurantDetailTwoColumnCell cell.column1TitleLabel.text = "Address" cell.column1TextLabel.text = restaurant.location cell.column2TitleLabel.text = "Phone" cell.column2TextLabel.text = restaurant.phone return cell case 2: let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: RestaurantDetailMapCell.self), for: indexPath) as! RestaurantDetailMapCell return cell default: fatalError("Failed to instantiate the table view cell for detail view controller") } }
In the code above, we just added a new case to handle the map cell. Let's hit the Run button to have a quick test. When you select a restaurant to navigate to the detail view, it shows a map. This is the power of MapKit. Without writing a line of code for the map view, you already embed a map within your app. Right now, it only displays a default map based on your current location. But it's really cool, right?
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Exploring Deepfakes by Bryan Lyon and Matt Tora(7735)
Robo-Advisor with Python by Aki Ranin(7630)
Offensive Shellcode from Scratch by Rishalin Pillay(6110)
Microsoft 365 and SharePoint Online Cookbook by Gaurav Mahajan Sudeep Ghatak Nate Chamberlain Scott Brewster(5030)
Ego Is the Enemy by Ryan Holiday(4958)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4438)
Python for ArcGIS Pro by Silas Toms Bill Parker(4186)
Elevating React Web Development with Gatsby by Samuel Larsen-Disney(3892)
Machine Learning at Scale with H2O by Gregory Keys | David Whiting(3630)
Learning C# by Developing Games with Unity 2021 by Harrison Ferrone(3285)
Speed Up Your Python with Rust by Maxwell Flitton(3231)
Liar's Poker by Michael Lewis(3227)
OPNsense Beginner to Professional by Julio Cesar Bueno de Camargo(3195)
Extreme DAX by Michiel Rozema & Henk Vlootman(3172)
Agile Security Operations by Hinne Hettema(3124)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic and Jasmin Redzepagic(3109)
Essential Cryptography for JavaScript Developers by Alessandro Segala(3083)
Cryptography Algorithms by Massimo Bertaccini(3002)
AI-Powered Commerce by Andy Pandharikar & Frederik Bussler(2983)
