34,333
edits
Changes
no edit summary
<seo title="Implementing iOS 11 TableView Navigation using Storyboards in Xcode 9" titlemode="replace" keywords="ios 11, swift 4, tableview, navigation, xcode 9" description="An iOS tableview navigation tutorial using storyboards and dynamic table view cells"></seo>
<htmlet>ios11</htmlet>
The objective of this chapter is to extend the application created in the previous chapter (entitled Using Xcode 9 Storyboards to Build Dynamic TableViews) and, in so doing, demonstrate the steps involved in implementing table view navigation within a storyboard. In other words, we will be modifying the attractions example from the previous chapter such that selecting a row from the table view displays a second scene in which a web page providing information about the chosen location will be displayed to the user. As part of this exercise we will also explore the transfer of data between different scenes in a storyboard.
Build and run the application and note that selecting a row in the table view now displays the second view controller which, in turn, has a button in the toolbar to return to the “Attractions” table view. Clearly, we now need to do some work on the AttractionDetailViewController class so that information about the selected tourist location is displayed in the view.
<htmlet>ios11</htmlet>
== Modifying the AttractionDetailViewController Class ==
The first task performed by this method is to check that the triggering segue is the ShowAttractionDetails segue we added to the storyboard. Having verified that to be the case the code then obtains a reference to the view controller of the destination scene (in this case an instance of our AttractionDetailViewController class). The table view object is then interrogated to find out the index of the selected row which, in turn, is used to prime the URL string variable in the AttractionDetailViewController instance.
<htmlet>ios11</htmlet>
== Testing the Application ==
<htmlet>ios11</htmlet>