사용자가 핀을 누를 때 눌러주는 mapView가 있습니다. 한 번에 여러 개의 핀이있을 수 있으며 각 주석 뷰에는 눌려 질 때 새 뷰를 스택에 푸시하는 콜 아웃이 있습니다. 내가하고 싶은 일은 주석보기의 제목을 두 번째보기의 레이블로 전달하는 것입니다. 나는 두 번째보기를 호출하는 코드를 여기에콜 아웃이있는 여러 주석이있는 MapView, 다음 뷰에 제목을 전달하는 방법
-(void)press:(UILongPressGestureRecognizer *)recognizer
{
CGPoint touchPoint = [recognizer locationInView:worldView];
CLLocationCoordinate2D touchMapCoordinate = [worldView convertPoint:touchPoint toCoordinateFromView:worldView];
geocoder = [[CLGeocoder alloc]init];
CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
altitude:CLLocationDistanceMax
horizontalAccuracy:kCLLocationAccuracyBest
verticalAccuracy:kCLLocationAccuracyBest
timestamp:[NSDate date]];
[geocoder reverseGeocodeLocation:location
completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocoder:completionHandler: called");
if (error) {
NSLog(@"Geocoder failed with error: %@", error);
} else {
CLPlacemark *place = [placemarks objectAtIndex:0];
address = [NSString stringWithFormat:@"%@ %@, %@ %@", [place subThoroughfare], [place thoroughfare], [place locality], [place administrativeArea]];
if (UIGestureRecognizerStateBegan == [recognizer state]) {
addressPin = [[MapPoint alloc]initWithCoordinate:touchMapCoordinate
title:address];
[worldView addAnnotation:addressPin];
}
}
}];
}
: 그리고 내가 필요로 할 때 보통
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
PinViewController *pinViewController = [[PinViewController alloc]init];
[self passValues];
[[self navigationController]pushViewController:pinViewController animated:YES];
}
가 다운 될 것 핀의 유한 수없는, 그래서 어떻게 핀을 임의의 NSNumber 식별자를 제공 할 (물론 당신이 MyLocation 클래스에서 다른 변수를 사용할 수 있습니다) 선택 주석을 확인? –
내 예제에서는 맵에 create 및 next show annotations에 sqlite를 사용합니다. 나는 거기에 "자동 증가"와 ID가, 그래서 거기에 어떤 핀이 같은 ID를 가지고 방법이 없습니다. 주석을 배열에 저장하면 배열의 인덱스를 사용할 수 있습니다. – edzio27
그래서 이해가 안되는 것은 MyLocation 클래스의 주소 변수에 지오 코딩 된 주소를 저장하는 방법입니다. 너무 많은 질문을하는 것에 불쌍하지만 미안합니다. –