:) 선택한 주석의 속성을 검색 할 때 정말 이상한 문제가 있습니다. 다음은 내 문제에 대한 간단한 설명입니다.선택한 주석의 문제점
선택한 주석 배열의 첫 번째 객체를 새로운 배열로 전달합니다. 필요한 유일한 객체입니다 (Apple doc에 따라 selectedAnnotations 배열을 새 배열에만 전달 함). 첫 번째 개체를 선택합니다.하지만 인덱스 경로 0에서 selectedAnnotations 배열에서 개체를 직접 가져 오려고했는데 동일한 문제가).
그런 다음 개체를 사용자 지정 주석 개체로 변형합니다 (개체가 있어야하므로).
나중에 내 맞춤 주석 임시 객체의 속성에 액세스하려고합니다. 여기 모든 것이 헐렁 할 때입니다. 객체의 NSLog는 메모리 주소 만 보여줍니다. Text 속성이 null입니다. 그래서 기본적으로 나는 그것에 접근 할 수 없다.
내가 뭘 잘못하고 어떤 접근법을 사용해야하는지에 대한 도움을 주시면 감사하겠습니다. 친절하게 감사드립니다! 여기
코드입니다 :-(void) mapView:(MKMapView *)aMapView didSelectAnnotationView:(MKAnnotationView *)view
{
if ([view isUserInteractionEnabled])
// NSLog(@"Tapped!!!");
{
NSArray* selectedAnnotation=mapView.selectedAnnotations;
CustomAnnotations *selectedAnn=[selectedAnnotation objectAtIndex:0];
NSLog(@"selected annotation text is %@", selectedAnn.text);
내 사용자 지정 주석 클래스는 좌표를 가지고 있으며, 텍스트 속성과이 코드를지도에 배치되는 것 : 주석에 대한
CustomAnnotations* commentAnnotation = [[[CustomAnnotations alloc] initWithLocation:mapView.userLocation.location.coordinate andTitle:@"comment" andText:text]autorelease];
[mapView addAnnotation:commentAnnotation];
또한,보기
-(MKAnnotationView *) mapView:(MKMapView *) aMapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKAnnotationView *customAnnotation = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"];
if(!customAnnotation)
{
customAnnotation = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"]autorelease];
}
customAnnotation.centerOffset=CGPointMake(10, -30);
if ([annotation title][email protected]"comment")
{
customAnnotation.userInteractionEnabled=YES;
customAnnotation.image=[UIImage imageNamed:@"NewCommentsPin.png"];
}
return customAnnotation;
}
어떤 도움을 주시면 감사하겠습니다.
문제점을 파악했습니다. 내 맞춤 주석 클래스가 dealloc에서 텍스트를 릴리스하고있었습니다. 출시시기와 한 번에 한 단계 씩 이해할 때까지 아직 갈 길이 멀다. :)