MKMap 引脚颜色不显示
Posted
技术标签:
【中文标题】MKMap 引脚颜色不显示【英文标题】:MKMap pin colors doesn't shows up 【发布时间】:2012-04-19 23:17:43 【问题描述】:我无法想象为什么它不起作用.. 我想更改引脚颜色,并使用此方法提供的其他一些东西,但它不起作用。 也许我使用这种方法错了? 最好有例子,谢谢。
[mapView setMapType: MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
for (NSDictionary *dict in self.klubiArray3)
double latid = [[dict valueForKey:@"LatiS"] doubleValue];
double longid =[[dict valueForKey:@"LongiS"] doubleValue];
MKCoordinateRegion region = 0.0, 0.0, 0.0, 0.0;
region.span.latitudeDelta = 0.005;
region.span.longitudeDelta = 0.005;
region.center.latitude = latid;
region.center.longitude = longid;
[mapView setRegion:region animated:YES];
NewClass *ann = [[NewClass alloc] init];
ann.title = [dict valueForKey:@"AnnotM"];
ann.subtitle = [dict valueForKey:@"Adress"];;
ann.coordinate = region.center;
[mapView addAnnotation:ann ];
#pragma mark MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
NSLog(@"Controll comes here");
if (annotation == mapView.userLocation)
return nil;
MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"];
if (pin == nil)
pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: @"asdf"] ;
else
pin.annotation = annotation;
pin.userInteractionEnabled = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton setFrame:CGRectMake(0, 0, 30, 30)];
pin.rightCalloutAccessoryView = disclosureButton;
pin.pinColor = MKPinAnnotationColorPurple;
//pin.animatesDrop = YES;
[pin setEnabled:YES];
[pin setCanShowCallout:YES];
return pin;
【问题讨论】:
【参考方案1】:发现,我忘记在 Interface Builder 中连接我的地图委托。
【讨论】:
以上是关于MKMap 引脚颜色不显示的主要内容,如果未能解决你的问题,请参考以下文章