MKMapView, animateDrop?

后端 未结 3 1727
盖世英雄少女心
盖世英雄少女心 2020-12-09 04:37

I have setup an NSMutableArray of objects derived from a class that conforms to the MKAnnotation protocol. I have setup setup title and subtitle for the annotation and have

3条回答
  •  天命终不由人
    2020-12-09 05:36

    Here's the most simple solution I could find. What it does is drops a single pin on the UIMapView in viewDidLoad event.

    1. The project references MapKit framework

    2. The view have the following import:#import

    3. The view controller implements MKMapViewDelegate protocol

    4. The view controller implementation contains:

    - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) annotation
    {
        MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"];
        newAnnotation.pinColor = MKPinAnnotationColorGreen;
        newAnnotation.animatesDrop = YES; 
        newAnnotation.canShowCallout = NO;
        [newAnnotation setSelected:YES animated:YES]; 
        return newAnnotation;
    }
    
    1. The viewDidLoad contains:
    CLLocationCoordinate2D geos = CLLocationCoordinate2DMake(0.2344, 45.324);
    MKPlacemark* marker = [[MKPlacemark alloc] initWithCoordinate:geos addressDictionary:nil];
    [mapView addAnnotation:marker];
    [marker release];
    

提交回复
热议问题