我使用UITableViewController在每个单元格上显示Map Annotations。我在每个单元格中添加了10个注释。我添加了viewForAnnotation委托方法来添加注释。我想为MKAnnotationView使用两个不同的图像。我可以为MKAnnotationView添加单个图像,但我不知道如何添加多个图像。
// MKAnnotationView delegate method showing required image.
- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id <MKAnnotation>)annotation {
NSLog(@"view for annotaion");
MKAnnotationView *annotationView = [[MKAnnotationView alloc]initWithAnnotation:annotation
reuseIdentifier:@"SearchMapTableAnnotation"];
annotationView.image = [UIImage imageNamed:@"handyman_ann_green.png"];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView; }
//CellForRowAtIndexPath method adding annotations to mapView.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
[mapView addAnnotations:latLongObject]; // latLongObject is NSArray
}