我嘗試不同的圖像添加到不同的註解視圖中添加不同的圖像,以不同的註解視圖,換句話說,我希望有一個獨特的PIC對應於每一個獨特的針。下面是我想:在Xcode
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"welcome into the map view annotation");
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
// try to dequeue an existing pin view first
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor=MKPinAnnotationColorPurple;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
if (CLLocationCoordinate2D == theCoordinate1) {
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Jeff.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
[profileIconView release];
}else if(CLLocationCoordinate2D = theCoordinate2) {
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Pierce.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
[profileIconView release];
}
我正在一個錯誤,我寫
if (CLLocationCoordinate2D == theCoordinate1) {
行我不知道相當什麼是錯的,也不是我能想出其他方法標識個人註釋。任何幫助是極大的讚賞!!
傑夫,歡迎來到SO!儘量避免在代碼粘貼中使用製表符 - 嘗試使用空格代替 - 在您的問題中使代碼格式正確。那麼幫助你更容易! – makdad 2011-05-27 02:07:57