いつもお世話になっております。
現在、objective-cで地図アプリを作成しています。
そこで、ピンを立てて選択すると別画面に遷移し、ピンを削除するかを選択して、削除するを選択すると前の画面に戻り遷移する前に選択したピンを消すという処理を行いたいのですが、 選択されたピンが消えず、一番最後に立てたピンが消えてしまいます....
この問題の解決方法を知っている方がおりましたら教えていただけると幸いです。
よろしくお願いいたします。
objective
1 2 3- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation //ピンのカスタマイズをするとこ 4{ 5 6 // 表示するアノテーションがCurrent Locationの場合はスルーする 7 if([annotation.title isEqualToString:@"Current Location"]){ 8 return nil; 9 } 10 11 NSString *identifier = @"MyPin"; 12 MKPinAnnotationView *pin = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; // 識別子で刺したピンを参照する 13 14 if(pin == nil){ // ピンがなければピンを作る 15 NSLog(@"pin == nil"); 16 pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 17 pin.animatesDrop = YES; // アニメーションをする 18 pin.draggable = YES; //ピンのドラッグ可能 19 20 21 pin.canShowCallout = YES; // ピンタップ時にコールアウト(吹き出し)を表示する 22 [pin setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]]; 23 } 24 return pin; 25} 26-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{ //ピンの詳細画面に飛ぶ 27 28 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 29 pin_settingViewcontroller = [storyboard instantiateViewControllerWithIdentifier:@"pin_setting"]; 30 [self.navigationController pushViewController:pin_settingViewcontroller animated:YES]; 31 32} 33-(void)remove_pin{ //この関数を遷移後の画面でdelegateでよぶ 34 [mv removeAnnotation:myPin]; 35} 36
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/10/26 12:45
2015/10/27 03:49
2015/10/31 04:31