Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
How would you set a mapview to only show callout arrows on some of the annotations? Some of my annotations are for landmarks and do not need to display anything other than a title and subtitle.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Do they contain an object? For example, a custom made object, or a string you could make an custom init method with?
Then you can compare strings, to decide wether it should show call out or not.
 

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
Do they contain an object? For example, a custom made object, or a string you could make an custom init method with?
Then you can compare strings, to decide wether it should show call out or not.

Not sure. Here is how I plot the annotations
Code:
 DisplayMap *ann28 = [[DisplayMap alloc] init];
    ann28.title = @"Freeman Tower";
    ann28.subtitle = @"";
    ann28.coordinate = tower;
    
    [mapView addAnnotation:ann28];
I add each annotation to a MutableArray called annotations, and then I have this method set up
Code:
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
    MKPinAnnotationView *pinView = nil;
    if(annotation != mapView.userLocation)
    {
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
                                          initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
                   pinView.pinColor = MKPinAnnotationColorRed;
            pinView.canShowCallout = YES;
            pinView.animatesDrop = YES;
            UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
            [detailButton setTitle:annotation.title forState:UIControlStateNormal];
            NSInteger annotationValue = [self.annotations indexOfObject:annotation];
            
            detailButton.tag = annotationValue;
            
            [detailButton addTarget:self action:@selector(showDetailView:) forControlEvents:UIControlEventTouchUpInside];
            
            pinView.rightCalloutAccessoryView = detailButton;
            return pinView;

        
            }
    else {
        [mapView.userLocation setTitle:@"I am here"];
    }
    return pinView;
}
I tried adding
Code:
ann28.accessibilityHint = @"YES";
and then in the annotationView adding
Code:
if (annotations.accessibilityHint == @"YES" {
 pinView.pinColor = MKPinAnnotationColorRed;
            pinView.canShowCallout = YES;
            pinView.animatesDrop = YES;}
else {
 pinView.pinColor = MKPinAnnotationColorRed;
            pinView.canShowCallout = NO;
            pinView.animatesDrop = YES;}
But that just made it to where none of the pins would display even a Title. Am I even close to being on the right track?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.