What You Need to Know to Set Up a Weather Controller for Your iOS App on the iPad and iPhone - dummies

What You Need to Know to Set Up a Weather Controller for Your iOS App on the iPad and iPhone

By Jesse Feiler

You can add a custom view controller to your iOS app for displaying the weather, which is actually pretty easy. As is always the case, the view controller will be interacting with a view (actually a hierarchy of views) in a storyboard. There’s one view controller and two storyboards—one for iPad and one for iPhone.

The iPad storyboard

Check out the Weather-related part of the iPad storyboard.

image0.jpg

The control flow through the iPad storyboard goes like this:

  1. The iPad user interface is controlled by an instance of Apple’s UISPlitViewController, which manages a Master View controller and a Detail View controller.

  2. The Master View controller, displayed on the left in Landscape orientation, has a relationship to a UINavigationController. This relationship is shown as an object in the storyboard file.

  3. The Detail View controller, which is always displayed, has a relationship with the custom WeatherController.

  4. You need a navigation controller as a wrapper around the Table view that is displayed in the Master View controller (there is another navigation controller used with the Events controller).

  5. The first navigation controller has a relationship to your custom MasterViewController.

  6. The MasterViewController manages the Table view that you provide to let the user decide what should be displayed in the Detail view.

  7. You’ll create a Replace segue to connect the first (Weather) item in the Table view to your weather scene.

  8. You’ll use a UIWebView to display the contents of a web page inside your custom WeatherController. Voilà — the user can see a weather forecast.

The iPhone storyboard

Check out the Weather-related part of the iPhone storyboard.

image1.jpg

The control flow through the iPhone storyboard goes like this:

  1. The iPhone user interface is controlled by an instance of Apple’s UINavigationController. The Navigation controller is needed to allow the user to pop (for example, return from) any view controller that is pushed using the Push segue in Step 4.

  2. Your UINavigationController has a relationship to your Master View controller.

  3. The MasterViewController manages the Table view that you are using to let the user decide what should be displayed when a table element is selected.

  4. You’ll connect the first item in your MasterViewController to your WeatherController using a Push segue.

  5. You’ll use a UIWebView to display the contents of a web page inside your custom WeatherController. Voilà — the user can see a weather forecast.