我有一个必须推入地图的表格视图。我正在尝试从注释中获取标题以显示在地图视图中,并且我需要比较字幕值中的值以完全根据注释值在地图中显示,但我得到的地图是标题和字幕值。我不想显示字幕,但我希望它比较值这是我的代码:
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
MKAnnotationView *pinView = nil;
if(annotation != mapview.userLocation)
{
NSLog(@"%i",k);
static NSString *defaultPinID = @"defaultPinID";
pinView = (MKAnnotationView *)[mapview dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil ) pinView = [[[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
NSString *st=@"0";
NSString *str = [annotation subtitle];
if ([str isEqualToString:st]) {
//pinView.pinColor = MKPinAnnotationColorGreen;
pinView.image=[UIImage imageNamed:@"greyDot.png"];
//return pinView;
}
NSString *st1=@"10";
if ([str isEqualToString:st1]) {
//pinView.pinColor = MKPinAnnotationColorGreen;
pinView.image=[UIImage imageNamed:@"blackDot.png"];
//return pinView;
}
NSString *st2=@"20";
if ([str isEqualToString:st2]) {
//pinView.pinColor = MKPinAnnotationColorPurple;
pinView.image=[UIImage imageNamed:@"greendot.png"];
//return pinView;
}
NSString *st3=@"30";
if ([str isEqualToString:st3]) {
//pinView.pinColor = MKPinAnnotationColorRed;
pinView.image=[UIImage imageNamed:@"blueDot.png"];
//return pinView;
}
pinView.canShowCallout = YES;
infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
//Display *t=annotation;
infoButton.tag=k;
[infoButton addTarget:self action:@selector(pinLabelClicked:) forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = infoButton;
}
else {
[mapview.userLocation setTitle:@"I am here"];
}
return pinView;
//k++;
}
这是我生成注释的代码
- (void)generateAnnotations
{
[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];
[mapview setDelegate:self];
for( int i=0;i<[addressArray count];i++ ){
AddressInfo *address = [addressArray objectAtIndex:i];
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = [address.latitude floatValue];
region.center.longitude = [address.longitude floatValue];
region.span.latitudeDelta=10.01f;
region.span.longitudeDelta=10.01f;
[mapview setRegion:region animated:YES];
//[mapview setRegion:region animated:TRUE];
//[mapview regionThatFits:region];
DisplayMap *ann = [[DisplayMap alloc] init];
//ann.tt=i;
k=i;
ann.title = address.name;
ann.subtitle = [NSString stringWithFormat:@"%@",address.category];
ann.sa = address.streetaddress;
ann.sb = address.suburb;
ann.ph = address.phoneNo;
ann.index = i;
//ann.image = [NSString stringWithFormat@"image_%d.png",i];
ann.coordinate=region.center;
[mapview addAnnotation:ann];
[ann release];
}
}
我在这里所做的是我正在根据这个值比较类别值我需要在地图视图中显示带有相对颜色的图钉。任何人都知道如何做到这一点?