Ios 标注附件未出现
我正在尝试将常规详图索引附件添加到注释区域,但由于某些原因,它没有显示出来。 代码如下:Ios 标注附件未出现,ios,mkmapview,mkannotationview,mkpinannotationview,Ios,Mkmapview,Mkannotationview,Mkpinannotationview,我正在尝试将常规详图索引附件添加到注释区域,但由于某些原因,它没有显示出来。 代码如下: - (void) setupMap:(PFObject*) venue { ... OTNVenueAnnotation *annotation = [[OTNVenueAnnotation alloc] init]; annotation.coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude); an
- (void) setupMap:(PFObject*) venue {
...
OTNVenueAnnotation *annotation = [[OTNVenueAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude);
annotation.title = [[venue objectForKey:@"name"] uppercaseString];
annotation.venue = venue;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"identifier"];
customPinView.leftCalloutAccessoryView = rightButton;
[self.mapView addAnnotation: annotation];
}
尝试在地图视图视图的委托方法中为注释设置leftCalloutAccessoryView,例如:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView *annView= (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.leftCalloutAccessoryView = rightButton;
annView.canShowCallout = YES;
return annView;
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释
{
MKPinAnnotationView*annView=(MKPinAnnotationView*)[self.mapView dequeuereusableannotationview with identifier:@“identifier”];
UIButton*rightButton=[UIButton Button类型:UIButtonTypedTailButton];
annView.leftCalloutAccessoryView=rightButton;
annView.canShowCallout=是;
返回视图;
}