我嘗試在我的應用程序創建的地圖部分節目,但由於某些原因註釋不會將正確的MKMapView滑稽Buissness
MKMapView *mapView = (MKMapView*)self.view;
CLLocationCoordinate2D coordinate;
coordinate.latitude = 55.065767;
coordinate.longitude = -2.724609;
mapView.region = MKCoordinateRegionMakeWithDistance(coordinate, 500000, 500000);
mapView.delegate = self;
for (int i=0; i<1; i++) {
coordinate.latitude = latitude;
coordinate.longitude = longitude;
CLLocationCoordinate2D newCoord = {coordinate.latitude, coordinate.longitude};
PlaceAnnotation* annotation = [[PlaceAnnotation alloc] initWithCoordinate:newCoord];
//annotation.mTitle = companyTitle;
//annotation.mSubtitle = companyDescription;
[mapView addAnnotation:annotation];
[annotation release];
}
}
,並在我的地方annotaion
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate{
self = [super init];
if (self != nil) {
_coordinate = coordinate;
}
return self;
}
lattitude和longditude都有正確的值,我以前使用過這個代碼,但使用指向一個對象的數組,它工作正常,但是當我嘗試直接給它的值時,它會失敗
誰能幫我出
*編輯,對不起,我已經有我Viewforannotation剛剛在副本中錯過了
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *pinAnnotation = nil;
if(annotation != mV.userLocation)
{
static NSString *defaultPinID = @"myPin";
pinAnnotation = (MKPinAnnotationView *)[mV dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinAnnotation == nil)
pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinAnnotation.canShowCallout = YES;
//instatiate a detail-disclosure button and set it to appear on right side of annotation
}
return pinAnnotation;
[pinAnnotation release];
}