mapView에서 어노테이션과 관련된 문제가 있습니다. 내 요구 사항을 한 눈에 볼 수 있습니다.mkMapView에서 세그먼트를 바꿀 때 핀 색상을 변경할 수 없습니다.
사용자에게 회의 위치를 선택하도록 선택하고 싶습니다.
두 가지 옵션이 있습니다.
1) 나는 그가 끌어 어디서나 자신이 원하는 핀을 놓을 수 있습니다 데이터
또는
2)에 의해 근처의 목록을 제공한다!
그 때문에 하나의 세그먼트가 생성되었습니다. 데이터 근처의 첫 번째 인덱스 및 핀을 놓을 때의 두 번째 인덱스입니다. 첫 번째 옵션의
(는 "근처에 의해") 나는 판매자, 판매자와 구매자 사이의 역할의 위치와 중간 점의 위치에서 데이터 근처에 가져올 필요가있다. 그래서 Google api를 호출하고 위도와 경도를 세 번 통과시켜 데이터를 가져옵니다. 처음으로 데이터를 얻을 때 아무런 문제가 없습니다. 내 배열은 모든 데이터 (3 개의 응답 포함)로 채우고 핀 색상도 요구 사항에 따라 변경됩니다. 내가 드롭 핀을 클릭하면
역할 (레드 컬러) 판매자 (퍼플) 중간 지점 (녹색)
이제 모든 데이터가 배열에서 제거하고 하나의 핀이지도에 삭제됩니다.
지금까지 제대로 작동합니다.
하지만 다시 "가까운 곳"을 클릭하면 문제가 시작됩니다! 필자가 원하는대로 데이터를 제공하지만 핀 색상이 유지되지 않는 것은 틀림 없습니다.
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([segmentND selectedSegmentIndex]==0) {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)
[myMapView dequeueReusableAnnotationViewWithIdentifier:BridgeAnnotationIdentifier];
if (!pinView)
{
MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier] autorelease];
switch (self.pinColor) {
case 0:
{
customPinView.pinColor = MKPinAnnotationColorPurple;
}
break;
case 1:
{
customPinView.pinColor = MKPinAnnotationColorRed;
}
break;
case 2:
{
customPinView.pinColor = MKPinAnnotationColorGreen;
}
break;
default:
break;
}
customPinView.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
return customPinView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else {
// Code of dragging dropping pin. It works Fine.s
}
}
자세한 내용은 image을 첨부하고 있습니다.
해결 방법이나 다른 방법으로 구현하십시오. 핀 색상은 판매자 구매자와 중간 점을 구별하는 데 필수적임을 기억하십시오!
컨트롤이 내부에 들어가거나 브레이크 포인트를 사용하지 않는 스위치 조건을 – Rajneesh071
self.pinColor는 어떤 값을 유지합니까? – Neo