0

When I try to drag the pin, it does not move. When I touch it, it darkens. However, it never lifts up, and it never moves around.

Here is the header file for my annotation class:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <Parse/Parse.h>

@interface GeoPointAnnotation : NSObject <MKAnnotation>

- (id)initWithObject:(PFObject *)aObject;

@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *subtitle;

- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate;

@end

Here's where I create the annotation in my view controller:

- (void)updateMap
{
    [self.mapView removeAnnotations:self.mapView.annotations];

    PFGeoPoint *geoPoint = [self.post location];

    // center the map around the geopoint
    [self.mapView setRegion:MKCoordinateRegionMake(
       CLLocationCoordinate2DMake(geoPoint.latitude, geoPoint.longitude),
       MKCoordinateSpanMake(0.01, 0.01)
       )];

    GeoPointAnnotation *annotation = [[GeoPointAnnotation alloc] initWithObject:self.post.object];
    [self.mapView addAnnotation:annotation];
}

// from Geolocations by Parse
#pragma mark - MKMapViewDelegate

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    static NSString *GeoPointAnnotationIdentifier = @"RedPin";

    MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:GeoPointAnnotationIdentifier];

    if (!annotationView) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:GeoPointAnnotationIdentifier];
        annotationView.pinColor = MKPinAnnotationColorRed;
        annotationView.canShowCallout = YES;
        annotationView.draggable = YES;
        annotationView.animatesDrop = YES;
    }

    return annotationView;
}

Any ideas?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Elliot
  • 6,086
  • 11
  • 45
  • 57

1 Answers1

1

Found the problem: I forgot to hook up the Map View's delegate in my Storyboard xib. h/t Nitin Gohel - thanks!

Elliot
  • 6,086
  • 11
  • 45
  • 57