- Hands-On Full:Stack Development with Swift
- Ankur Patel
- 352字
- 2021-08-27 19:39:47
Wiring up the view
Storyboard is where you define the flow of your application. It's where the initial View Controller is defined and also the place where you can set up other View Controllers and connect them. Configuring our app's UI is done using Xcode, but all of these configurations can be programmatically done by writing additional code.
To use our new TableViewController file in our application, we need to edit our main storyboard. To do so, we need to perform the following steps:
- Delete the ViewController.swift file in our project as we will not be using it. You can do so by right-clicking on the file, selecting Delete, and then in the modal selecting Move to Trash.
- Open the Main.storyboard. We will click on View Controller Scene in the left pane of our storyboard file and delete it:

- Drag the Navigation Controller from the Object Library on the bottom right-hand corner of Xcode. You can filter for it by typing Navigation Controller in the filter field. Navigation Controller comes with a Table View Controller when you drag it into the storyboard and it will be set as the Root View Controller:

- Click on the Root View Controller and then go to the Identify Inspector which is on the top right corner of Xcode. In Class field, type ItemTableViewController, our newly created controller:

- Tell storyboard that the Navigation Controller is our Initial View Controller and to start the app from there. We can do so by first selecting Navigation Controller, then selecting the Attributes Inspector tab in the top-right corner and checking the Is Initial View Controller checkbox. As a confirmation, we will not see an arrow to the left of our Navigation Controller in the storyboard:

- Run the app by clicking on the play button on the top-left corner of Xcode to make sure we have wired everything correctly and the app runs:

The app will not do anything exciting, but in the next section we will write code in our Table View Controller to start creating, editing, and deleting our Shopping List Items:

推薦閱讀
- 物聯網網絡安全及應用
- Hands-On Chatbots and Conversational UI Development
- Go Web Scraping Quick Start Guide
- 局域網組建、管理與維護項目教程(Windows Server 2003)
- Getting Started with WebRTC
- Socket.IO Real-time Web Application Development
- 數字通信同步技術的MATLAB與FPGA實現:Altera/Verilog版(第2版)
- Mastering JavaFX 10
- Metasploit Penetration Testing Cookbook
- 6G:面向2030年的移動通信
- 物聯網工程導論(第3版)
- 5G+區塊鏈
- Qt5 Python GUI Programming Cookbook
- 物聯網概論
- ElasticSearch Server