MKAnnotation に問題があります。カスタム pinview を使用すると、最初の読み込みで問題なく動作します。ピンを削除してから、色が変わる同じピンをリロードします。2 つの異なる DB からピンを追加すると、問題なく動作します。削除してから各配列を個別に追加すると、2 番目の配列は、割り当てられたものではなく、最初の配列のカスタム ピンを取得します。
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"pin";
pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil )
pinView = [[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"stores.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
NSString *badgestringss = @"8 reviews";
customBadge1 = [CustomBadge customBadgeWithString:badgestringss
withStringColor:[UIColor whiteColor]
withInsetColor:RGB(255, 51, 0)
withBadgeFrame:YES
withBadgeFrameColor:[UIColor whiteColor]
withScale:1.0
withShining:YES];
[customBadge1 setFrame:CGRectMake(100, 1, 85, 15)];
[pinView.leftCalloutAccessoryView addSubview:customBadge1];
if(setStoreOrShops==NO){
pinView.image = [UIImage imageNamed:@"stores.png"]; //as suggested by Squatch
}
else if (setStoreOrShops==YES){
pinView.image = [UIImage imageNamed:@"shops.png"];
}
else {
[mapView.userLocation setTitle:@"Current Location"];
}
}
return pinView;
}
あちこち検索しましたが、機能する例や、これが壊れている場所のアイデアが得られないようです。助けてくれてありがとう。