Я работаю над MKMap View, который показывает текущее местоположение на основе координаты местоположения и других пользовательских аннотаций. Он показывает правильно на Iphone 3gs, но на iphone 4.0 или выше он не показывает пользовательские аннотации каждый раз (случайным образом он показывает только зеленый контакт, а не другой). что может быть проблемой? есть ли проблема в ios 4.0 и выше? если да, то как мы можем решить .can кто-нибудь помочь мнеIos 4 - Mkmap размещение пользовательских комментариев аннотации
Благодаря
код из метода viewForAnnotation ...
if ([annotation isMemberOfClass:[MKUserLocation class]])
{
return nil;
}
if (annotation==self.normalAnnotation)
{
NSLog(@"green pin");
MKPinAnnotationView *annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"NormalAnnotation"] autorelease];
annotationView.canShowCallout = NO;
annotationView.pinColor = MKPinAnnotationColorGreen;
return annotationView;
}
else
{
NSLog(@"Custom pin");
Marker *obj = [database getMarkerWithName:[annotation title]];
MKAnnotationView *newAnnotation=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"]autorelease];
newAnnotation.image = [UIImage imageNamed:obj.markerImage];
newAnnotation.canShowCallout=YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[button setTag:obj.markerID];
newAnnotation.rightCalloutAccessoryView=button;
//annotation.annotationObj = newAnnotation;
return newAnnotation;
}
Показать код для метода viewForAnnotation. – Anna
Привет Спасибо за ур ответ, вот мой код – ratnasomu
если ([аннотаций isMemberOfClass: [класс MKUserLocation]]) \t \t { \t \t \t возвратного ноль; \t \t} \t \t , если (== аннотаций self.normalAnnotation) \t { \t \t NSLog (@ "зеленый штырь"); \t \t MKPinAnnotationView * annotationView = [[[MKPinAnnotationView Alloc] initWithAnnotation: аннотацию \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t reuseIdentifier: @ "NormalAnnotation"] autorelease]; \t \t annotationView.canShowCallout = NO; \t \t annotationView.pinColor = MKPinAnnotationColorGreen; \t \t return annotationView; \t} \t еще \t { \t \t NSLog (@ "Custom штырь"); \t \t Маркер * obj = [база данных getMarkerWithName: [название аннотации]]; – ratnasomu