我繼承了這行拋出這個警告MKPinAnnotationView與MKAnnotationView
Incompatible pointer types assigning to 'MKPinAnnotationView *' from 'MKAnnotationView *'
項目
pinView=[[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID]autorelease];
}
我想沒有警告回報的項目,所以我在這裏希望有人有一個快速的答案
全碼:
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = nil;
NSUserDefaults *prefs=[NSUserDefaults standardUserDefaults];
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (!pinView) {
pinView=[[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID]autorelease];
}
}
pinView.animatesDrop=YES;
[mapView.userLocation setTitle:@"I am here"];
[mapView.userLocation setSubtitle:[prefs objectForKey:@"CurrentLocationName"]];
return pinView;
}
謝謝!