In this episode, we continue with the simple app. We add a map and set up a push segue to get to it.
This is a multi-part video tutorial series, so be sure to subscribe to the newsletter to be notified when the next episode releases.
Video Tutorial
Finished Project
Relevant code
let location = CLLocationCoordinate2D(latitude: 37, longitude: -122) let coordinateSpan = MKCoordinateSpan(latitudeDelta: 10, longitudeDelta: 10) mapObject.addAnnotation(location, withPinColor: .Purple) mapObject.setRegion(MKCoordinateRegion(center: location, span: coordinateSpan))
Tutorial Steps
Drag an interface controller from the object library to the storyboard.
Add a map object onto it.
Drag a button onto the original controller.
Control-drag from the button to the new controller and select 'push'.
Create a new interface controller file in the WatchKit Extension.
Add code for a location with latitude and longitude.
Add code for a coordinate span to set the zoom level.
Add a colored pin.
Finally set the map's region with the location and coordinate span.
Build and run the app to see it in the iOS Simulator for Apple Watch.