내 코드가지도 주석을 제거하지 않는 이유는 무엇입니까?지도 제거 버튼 클릭시 주석 주석 (생성 된 주석)
버튼을 눌렀을 때 사용자 위치를 얻은 다음지도에 고정합니다. 문제는 버튼이 두 번째, 세 번째, ....... 시간에 도달했을 때입니다. 단지 첫 번째 핀을 제거하는 대신 핀을 계속 추가하는 것입니다 (핀 교체 시뮬레이션).
다른 버튼 (클리어 핀)을 추가하고이 스레드 다음을 시도했습니다. http : //stackoverflow.com/questions/3027392/how-to-delete-all-annotations-on-a-mkmapview 디버그 정보없이 충돌합니다.
하지만 이론 상으로는 내 코드가 작동해야합니다. 그래서 나는 무엇을 이해하지 못합니까? 제거 후, 당신은지도에 주석을 찾을 수 있습니다
MapAnnotation *ann1 =[[[MapAnnotation alloc] init]autorelease];
// remove annotation
[mapView removeAnnotation:ann1];
및 :
- (IBAction)getLocation:(id)sender {
MapAnnotation *ann1 =[[[MapAnnotation alloc] init]autorelease];
// remove annotation
[mapView removeAnnotation:ann1];
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter=kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
MKCoordinateRegion region = {{0.0,0.0},{0.0,0.0}};
region.center.latitude = locationManager.location.coordinate.latitude;
region.center.longitude = locationManager.location.coordinate.longitude;
region.span.longitudeDelta = 0.005f;
region.span.latitudeDelta = 0.005f;
[mapView setRegion:region animated:YES];
[mapView setDelegate:sender];
MKCoordinateRegion location1;
location1.center.latitude =locationManager.location.coordinate.latitude;
location1.center.longitude= locationManager.location.coordinate.longitude;
location1.span.longitudeDelta=0.1;
location1.span.latitudeDelta =0.1;
// Add Annotation
//MapAnnotation *ann1 =[[MapAnnotation alloc] init];
[email protected]"You Parked Here";
[email protected]"";
ann1.coordinate= location1.center;
[mapView addAnnotation:ann1];
}
정말 고마워요. } [: 주석지도보기 removeAnnotation] { 계속 : (주석의 ID 주석) { 경우 ([[MKUserLocation 클래스] 주석 isKindOfClass])에 대한; 나는 [지도보기 주석] "있는 NSArray * 주석 = 시도했다 ; } "하지만 계속 충돌했습니다. 좋은 작품입니다. – Rick
소리가 나는 것처럼 보입니다 ... 배열을 사용하는 동안 배열을 변경하고 싶지는 않습니다. – joshpaul
데이터베이스에서 핀 레코드를 제거하려는 경우이 논리를 사용하여 맵에서 올바른 핀을 제거 할 수 있습니까? 핀을 클릭하면 pin_id와 함께 모든 레코드를 얻고 있는데 클릭 한 핀의 핀 ID를 찾을 수 없습니까? 이 상황에서 나올 수 있도록 도와 주시겠습니까? –