my MKAnnotationVIew is not showing the title

Posted by hydev on Stack Overflow See other posts from Stack Overflow or by hydev
Published on 2011-01-10T22:17:25Z Indexed on 2011/01/11 0:53 UTC
Read the original article Hit count: 416

Filed under:
|
|

Hi,

I am new to iPhone programming and I can't understand why the MKAnnotationView is not showing the title's of my annotation's. Below is the code that is used to display it on the map.

- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
NSLog(@"Entered didAddAnnotationViews");

MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 250, 250);
[mv setRegion:region animated:YES];
}

Here is where I am defining my annotations:

MapPoint *mp = [[MapPoint alloc]
                    initWithCoordinate:[newLocation coordinate]
                                 title:[locationTitleField text]];

[mapView addAnnotation:mp];
[mp release];

mp is a class I have created to keep track of all the map points:

#import "MapPoint.h"

@implementation MapPoint
@synthesize coordinate, title;

- (id)initWithCoordinate:(CLLocationCoordinate2D)c title:(NSString *)t
{
[super init];
coordinate = c;
[self setTitle:t];
return self;
}

- (void)dealloc
{
[title release];
[super dealloc];
}
@end

I am beginner so go easy, and all help greatly appreciated.

Mike

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mapkit