Question

i added an annotation and in viewforannotation i set canshowcallout and selected the annotation as well but it aint getting selected...

  -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
    currentCoordinates = newLocation.coordinate;
 ParkPlaceMark *pa = [[ParkPlaceMark alloc] init];
        pa.coordinate = currentCoordinates;
        pa.title = @"POI";
        pa.title2 = @"CUrrent Locn";
        pa.subtitle = @"Drag and drop to adjust the position if necessary";
        [mapView addAnnotation:pa];
        [pa release];
   }
   - (MKAnnotationView *)mapView:(MKMapView *)map
        viewForAnnotation:(ParkPlaceMark*)annotation {

MKAnnotationView *test=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
if([annotation.title caseInsensitiveCompare:@"POI"] == NSOrderedSame)
{
    test.annotation = annotation;

    test.userInteractionEnabled = YES;
    test.draggable = YES;
    //        test.pinColor = MKPinAnnotationColorRed;

    [test setImage:[UIImage imageNamed:@"marker3.png"]];
    [test setEnabled:YES];
    [test setCanShowCallout:YES];
    [test setDragState:MKAnnotationViewDragStateEnding animated:YES];
    [self.mapView selectAnnotation:test.annotation animated:YES];
    return test;
   }
  }
Was it helpful?

Solution

I had added custom animation so

  [self.mapView selectAnnotation:test.annotation animated:YES];

was not working . The correct code is :

  [self.mapView selectAnnotation:test.annotation animated:NO];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top