Setting up a Tab Bar Controller Scene and Launch screen 

As you saw in the app tour, the Let's Eat app has a Tab Bar with two buttons at the bottom of the screen, which are used to display the Explore and Map screens. In this section, you will remove the existing View Controller Scene and ViewController.swift file and add a Tab Bar Controller Scene with two buttons to your project. Perform the following steps:

  1. Click Main.storyboard in the Project navigator:

  1. The contents of Main.storyboard appear in the Editing area. Click the Document Outline button to collapse the document outline. This gives you more room to work with:

  1. Click the + button to open the Object library:

  1. The Object library allows you to pick UI objects that you can add to a scene. Type tabbar in the filter field. A Tab Bar Controller object will appear in the list of results:

  1. Drag the Tab Bar Controller object to the storyboard. It's okay if it covers the existing View Controller Scene. You can see it consists of a scene with two arrows leading to two more scenes. These arrows represent segues:

  1. Click the - button to zoom out, and rearrange the scenes in the storyboard so the Tab Bar Controller Scene is not covering the View Controller Scene:

  1. Drag the arrow from the View Controller Scene to the Tab Bar Controller Scene as shown. This will set the Tab Bar Controller as the initial View Controller of your project, making the Tab Bar appear when you launch your app:

  1. Select the existing View Controller Scene and press Delete on the keyboard to remove it, as you won't be using it for this project:

  1. Select ViewController.swift in the Project navigator and press Delete on the keyboard to remove it, as you won't be using it for this project:

  1. Click Move to Trash in the dialog box that pops up:

  1. If you see a second editor window appear, click the Adjust Editing Option button and choose Show Editor Only:

When you build and run your app in the Simulator, you'll see the tab bar with two buttons at the bottom of the screen:

You have successfully added a Tab Bar to your project, but as you can see, the button titles are currently Item 1 and Item 2. You will change them to Explore and Map in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.51.241