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;
- 开发者_JAVA技巧(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
Hi did you look at apple "MapCallouts" example? you can find it here -
http://developer.apple.com/library/ios/#samplecode/MapCallouts/Introduction/Intro.html
look at it and i would love to help if you have more questions.
shani
精彩评论