0
일부 annotationView의 경우 일부 하위 레이어를 설정했습니다. 첫 번째로드 하위 레이어는 이미지와 일치하지만,지도를 새로 고침 (clear annotationView 및 다시 구문 분석 정보) 할 때 하위 레이어가 장소 및 이미지와 일치하지 않을 경우 이 표시됩니다. 그리고 각 새로 고침 하위 계층이 다른 위치에 나타납니다.새로 고침 후 CALayer가 다른 사용자에게 설정 됨 annotationView
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
SYLocationItem * currentItem;
static NSString *identifier = @"SYLocationItem";
if ([annotation isKindOfClass:[SYLocationItem class]]) {
CATextLayer* subtitle1Text = [CATextLayer layer];
CALayer *sublayer = [CALayer layer];
MKAnnotationView *annotationView = (MKAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationView.enabled = YES;
annotationView.canShowCallout = NO;
} else {
annotationView.annotation = annotation;
}
currentItem = annotationView.annotation;
SYJabberClient *client = [SYJabberClient sharedClient];
[client retrieveProfileForUserWithEmail:[(SYLocationItem*)annotation email]
withSuccessBlock:^(NSDictionary *dict, NSError *error) {
if (dict) {
UIImage *image = [dict objectForKey:@"imageFile"];
UIImage *displayImage = [UIImage circularScaleNCrop:image
withRect:
CGRectMake(0.0f,0.0f,30.0f,30.0f)];
annotationView.image = displayImage;
if(currentItem.groupSamePlace != nil){
sublayer.backgroundColor = [UIColor redColor].CGColor;
sublayer.cornerRadius = 9.0;
sublayer.frame = CGRectMake(20, -7, 20, 20);
[subtitle1Text setFontSize:12];
[subtitle1Text setFrame:CGRectMake(0, 3, 20, 20)];
NSString *string = [NSString stringWithFormat:@"%@", currentItem.samePlaceCount];
[subtitle1Text setString:string];
[subtitle1Text setAlignmentMode:kCAAlignmentCenter];
[subtitle1Text setForegroundColor:[[UIColor whiteColor] CGColor]];
[sublayer addSublayer:subtitle1Text];
[annotationView.layer addSublayer:sublayer];
}
}
}];
return annotationView;
}
return nil;
}
추신 올바른 위치에 이미지가 있습니다.