Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Swift 2 Blueprints

You're reading from   Swift 2 Blueprints Swift Blueprints

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781783980765
Length 276 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Costa Costa
Author Profile Icon Costa
Costa
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Swift 2 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Exploring Xcode FREE CHAPTER 2. Creating a City Information App with Customized Table Views 3. Creating a Photo Sharing App 4. Simulating Home Automation with HomeKit 5. Health Analyzing App Using HealthKit 6. Creating a Game App Using SpriteKit 7. Creating an Apple Watch App 8. AVFoundation Index

Adding the page view controller


To display the city's information, we are going to use a page view controller. This way, we can navigate through its information as if we were reading a book. To do it, we are going to add a new file called CityOptionsViewController.swift to the ViewControllers group.

Open this file and create a class that inherits from UIPageViewController and also stores CityInfo. This class should also be its own data source, as it needs to know which view controller comes next when the user decides to turn a page. As we don't yet have any of the view controllers that are going to hang from this page view controller, we are going to implement the mandatory methods that will return nil. Let's start implementing the CityOptionsViewController class with a minimum code by typing the following code:

import UIKit

class CityOptionsViewController : UIPageViewController, UIPageViewControllerDataSource {
    var cityInfo:CityInfo!
    override func viewDidLoad() {
        super.viewDidLoad...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images