MKAnnotation Title

Discussion in 'iOS Programming' started by marcomn, Dec 8, 2009.

  1. macrumors newbie

    Joined:
    Dec 8, 2009
    #1
    Hello, please could anybody help me, i don't know more.
    i have programmed an app, which loads a lot of points in maps and show it.
    but now the problem is how I can write a title an subtitle for each annotation?
    this is the code for my class which sets up the annotations:

    Code:
    #import "EarthquakeEventView.h"
    
    @implementation EarthquakeEventView
    
    - (id)initWithAnnotation:(id <MKAnnotation>)annotation 
             reuseIdentifier:(NSString *)reuseIdentifier {
      if(self = [super initWithAnnotation:annotation 
                          reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
      }
      return self;
    }
    
    - (NSString *)subtitle{
    		return @"Adresse";
    }
    
    - (NSString *)title{
    		return @"Name";
    }
    
    - (void)setAnnotation:(id <MKAnnotation>)annotation {
    	super.annotation = annotation;
      if([annotation isMemberOfClass:[SeismicEvent class]]) {
        event = (SeismicEvent *)annotation;
        float magSquared = event.magnitude * event.magnitude;
        self.frame = CGRectMake(0, 0, magSquared * .75,  magSquared * .75);
      } else {
        self.frame = CGRectMake(0,0,0,0);
      }
    
    }
    - (void)dealloc {
      [event release];
      [super dealloc];
    }
    
    @end
    
    please help me, thanks
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Does EarthquakeEventView implement the MKAnnotation protocol?
     

Share This Page