我添加了一个注释,在viewforannotation中,我设置了canshowcallout并选择了注释,但它不会被选中...
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
currentCoordinates = newLocation.coordinate;
ParkPlaceMark *pa = [[ParkPlaceMark alloc] init];
pa.coordinate = currentCoordinates;
pa.title = @"POI";
pa.title2 = @"CUrrent Locn";
pa.subtitle = @"Drag and drop to adjust the position if necessary";
[mapView addAnnotation:pa];
[pa release];
}
- (MKAnnotationView *)mapView:(MKMapView *)map
viewForAnnotation:(ParkPlaceMark*)annotation {
MKAnnotationView *test=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
if([annotation.title caseInsensitiveCompare:@"POI"] == NSOrderedSame)
{
test.annotation = annotation;
test.userInteractionEnabled = YES;
test.draggable = YES;
// test.pinColor = MKPinAnnotationColorRed;
[test setImage:[UIImage imageNamed:@"marker3.png"]];
[test setEnabled:YES];
[test setCanShowCallout:YES];
[test setDragState:MKAnnotationViewDragStateEnding animated:YES];
[self.mapView selectAnnotation:test.annotation animated:YES];
return test;
}
}
我添加了自定义动画,所以
[self.mapView selectAnnotation:test.annotation animated:YES];
不起作用.正确的代码是:
[self.mapView selectAnnotation:test.annotation animated:NO];