Giter Site home page Giter Site logo

lifeanddeath's Introduction

LifeAndDeath

A simple iOS application that demonstrates MapKit use by showing life events on a Map.

Follow these steps to integrate MapKit

Preparation

  1. Add the MapKit framework to the project
  2. Import MapKit and conform to the MKMapViewDelegate on the MapDetailViewController
  3. Change the @import CoreLocation to @import MapKit in the Entry.h file
  4. Add an enum for LifeEvents to the Person class, we will use this for creating MKAnnotations
  5. Update the cellSelectionStyle in the storyboard to Blue and add a segue to the MapDetailViewController

Annotations

  1. Add an outlet for the MapView to the MapDetailViewController
  2. Set the MapDetailViewController as the delegate for the MapView
  3. Add a new PersonAnnotation class with a custom init method - (PersonAnnotation *)initWithPerson:(Person *)person lifeEvent:(LifeEvent)event. You will need a synthesized CLLocationCoordinate2D property called coordinate to conform to the MKAnnotation protocol. In the custom init method, set the coordinate property to the property matching the life event's location's coordinate.
  4. Add an updateWithPerson method that will add the annotations for birthPlace and deathPlace to the map, run the method in the view did load with self.person (which will get set by the list view controller)
  5. Prepare the MapView with the - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation method. Use an MKPinAnnotationView, set the pin color, and set canShowCallout to YES.

Tying Things Together

  1. Add an outlet for the TableView on the list view controller
  2. Prepare for the segue by setting the Person property and running updateWithPerson on the MapDetailViewController when the user selects a cell (you will need to get the indexPath of the cell to update with the correct person)

lifeanddeath's People

Contributors

calebhicks avatar

Watchers

James Cloos avatar Daniel Bladh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.