1

我的地图代码:

if (latitude != [NSNull null] && longitude != [NSNull null])
    {
    location.latitude=[latitude doubleValue];
    location.longitude=[longitude doubleValue];
    MyAnnotationView *newannotation=[[MyAnnotationView alloc]initWithTitle:[NSString stringWithFormat:@"Bus-%d",h] latitude:location.latitude longitude:location.longitude];
    [self.myMap addAnnotation:newannotation];
    myMap.mapType=MKMapTypeStandard;
    [myMap setCenterCoordinate:location animated:YES];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location,1000,1000);
    [myMap setRegion:region animated:YES];

    }

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

location.latitude=newLocation.coordinate.latitude;
location.longitude=newLocation.coordinate.longitude;
MyAnnotationView *newannotation=[[MyAnnotationView alloc]initWithTitle:[NSString stringWithFormat:@"Bus-%d",h] latitude:location.latitude longitude:location.longitude];
[self.myMap addAnnotation:newannotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location,1000, 1000);
[myMap setRegion:region animated:YES];
[myMap setCenterCoordinate:newLocation.coordinate animated:YES];
}

mkannotationview.h

@implementation MyAnnotationView
@synthesize title,coordinate;
-(id)initWithTitle:(NSString *)newTitle latitude:(float)newLatitude longitude:(float)newLongitude
{

    if (self=[super init])

    {
        title=newTitle;
        coordinate.latitude=newLatitude;
        coordinate.longitude=newLongitude;

    }
    return  self;
}

如何添加带有该标题的标注?当我单击该注释时,它不会弹出。单击时,出现以下线程错误

EXC_BREAKPOINT(code=EXC_1386+BPT,subcode 0.0)
4

0 回答 0