Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
iOS 10 Programming for Beginners

You're reading from   iOS 10 Programming for Beginners Explore the latest iOS 10 and Swift 3 features

Arrow left icon
Product type Paperback
Published in Dec 2016
Publisher Packt
ISBN-13 9781786464507
Length 678 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Craig Clayton Craig Clayton
Author Profile Icon Craig Clayton
Craig Clayton
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Getting Familiar with Xcode FREE CHAPTER 2. Building a Foundation with Swift 3. Digging Deeper 4. Digging into Collections 5. Starting the UI Setup 6. Setting Up UI 7. Getting Started with the Grid 8. Getting Started with the List 9. Working More with Lists 10. Where Are We? 11. Where's My Data? 12. Foodie Reviews 13. Saving Reviews 14. Universal 15. iMessages 16. Notifications 17. Just a Peek 18. Beta and Store Submission Index

Creating and adding annotations


Now, we need to get our Map hooked up and start getting the annotations displaying on the Map. Then, we will customize our annotations to look like those in our design.

Creating our Map View Controller

We need to create our Map View Controller file and then connect it with our UIViewController and Map View in Storyboard. First, let's create this file:

  1. In the Navigator panel, right-click on the Controller folder in the Map folder and select New File.

  2. Inside of the Choose a template for your new file screen, select iOS at the top and then Cocoa Touch Class. Then, hit Next.

  3. Add the following into the options screen that appears:

  4. New File:

    • Class: MapViewController

    • Subclass…: UIViewController

    • Also create XIB: Unchecked

    • Language: Swift

  5. Click on Next and then Create.

  6. Under the import UIKit statement, add import MapKit.

  7. Update your class declaration to include the following subclass:

    class MapViewController: UIViewController, MKMapViewDelegate

Let's now connect this file with our...

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 $19.99/month. Cancel anytime