Chapter 10
Displaying Alerts with UIAlertController and Handling Table View Selection

There is no learning without trying lots of ideas and failing lots of times.

- Jonathan Ive

Are you able to complete the previous exercise and create the custom table view? No worries if you can't. I will go through the solution with you in this chapter and introduce some new layout techniques. Up till now, we only focus on displaying data in a table view. I guess you may wonder how we can interact with the table view and detect row selections. This is what we will also discuss in this chapter.

To begin, first download the complete project we built in the previous chapter (http://www.appcoda.com/resources/swift55/FoodPinCustomTable.zip). We will continue to enhance the app and make it even better. In brief, here are what we are going to implement:

  • Add another prototype cell to the table view
  • Bring up a menu when a user taps a cell. The menu offers two options: Reserve a table and Mark as favorite.
  • Display a heart icon when a user selects Mark as favorite.

Through implementing these new features, you will also learn how to use two prototype cells and use UIAlertController to display alerts in iOS.

Figure 10-1. Sample alerts in Shortcut and Medium apps
Figure 10-1. Sample alerts in Shortcut and Medium apps

To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.

results matching ""

    No results matching ""