viewForAnnotation , delegate , viewDidLoad.
delegate:
mapHole = MKMapView(frame: mapRect.textRect)
mapHole.delegate = self // <-- add this line
span = MKCoordinateSpanMake(0.001, 0.001)
, , , MKMapViewDelegate. :
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
, delegate , , .
addStroke, , :
annotation.title = "Stroke"
/* This code doesn't belong here...
let useID = "test"
var myAnnotation = mapHole.dequeueReusableAnnotationViewWithIdentifier(useID)
if (myAnnotation == nil) {
myAnnotation = MKAnnotationView(annotation: annotation, reuseIdentifier: useID)
myAnnotation.image = UIImage(named: "ballSmall.png")
myAnnotation.canShowCallout = true
myAnnotation.enabled = true
} else {
myAnnotation.annotation = annotation
}
mapHole.viewForAnnotation(annotation)
*/
mapHole.addAnnotation(annotation)
viewDidLoad:
GPSspot = manager.location.coordinate
region = MKCoordinateRegion(center: GPSspot, span: span)
mapHole.setRegion(region, animated: true)
, manager.location nil , startUpdatingLocation. , manager.location nil, didUpdateLocations.
, :
... MKMapView , ( ), iPhone. ( , Xcode .)
, Xcode - IDE, . iOS SDK, , iPhone . SDK . "" / " " , WWDC, SO .