MKAnnotation shows that this is a marker graphic customized in a simulator but not on a device

advertisements

I had this working very early, but then it stopped and I have no idea why. Here is the code:

- (void)updateMarkers:(NSMutableArray *)myAudioLocationVOArray
{
 [self cleanupMarkers];

 NSLog(@"UPDATE ALL MARKERS");

 int tArrayCount = [myAudioLocationVOArray count];

 for (int i=0; i< tArrayCount; i = i + 1)
 {
  AudioLocationVO* tAudioLocVO = [myAudioLocationVOArray objectAtIndex:i];

  AudioAnnotation *tNewAnn = [[AudioAnnotation alloc] init];
  tNewAnn.coordinate = CLLocationCoordinate2DMake(tAudioLocVO.latitude, tAudioLocVO.longitude);
  // add current track if available
  tNewAnn.audioLocationVORef = tAudioLocVO;

  [self.mapView addAnnotation:tNewAnn];

  [tNewAnn release];
 }

}

- (void)cleanupMarkers
{
 NSLog(@"REMOVE ALL MARKERS");
 NSArray *tExistingPoints = self.mapView.annotations;
 if ([tExistingPoints count] > 0)
 {
  [self.mapView removeAnnotations:tExistingPoints];
 }
}

- (MKAnnotationView *)mapView:(MKMapView *)myMapView viewForAnnotation:(id <MKAnnotation>)myAnnotation
{

 if ([myAnnotation isKindOfClass:[AudioAnnotation class]])
    {
  AudioAnnotation *tAnnotation = (AudioAnnotation *)myAnnotation;

   MKAnnotationView *tNewMarkerView = [[[MKAnnotationView alloc] initWithAnnotation:tAnnotation reuseIdentifier:nil] autorelease];

   if(tAnnotation.audioLocationVORef.state == ANNOTATION_STATE_DROPPING)
   {
    NSLog(@"ADD DROP MARKER");
    [tNewMarkerView setImage:[UIImage imageNamed:@"greenmarker.png"]];
    tNewMarkerView.draggable = YES;
   }
   else
   {
    NSLog(@"ADD NEW MARKER");
    [tNewMarkerView setImage:[UIImage imageNamed:@"newMarker.png"]];
    tNewMarkerView.draggable = NO;
   }

   tNewMarkerView.frame = CGRectMake(tNewMarkerView.frame.origin.x,tNewMarkerView.frame.origin.y,20,26);

   tNewMarkerView.canShowCallout = YES;
   tNewMarkerView.enabled = YES;

   // callout button
   UIButton *tButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
   tNewMarkerView.rightCalloutAccessoryView = tButton;

   // cover art and title/subtitle
   UIButton *tCover = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
   if(tAnnotation.audioLocationVORef.trackVO==nil)
   {
    tAnnotation.title = @"Drop a Track";
    tAnnotation.subtitle = @"Choose a track to drop";
    [tCover setImage:[UIImage imageNamed:@"preCover.png"] forState:UIControlStateNormal];
   }
   else
   {
    tAnnotation.title = tAnnotation.audioLocationVORef.trackVO.songTitle;
    tAnnotation.subtitle = tAnnotation.audioLocationVORef.trackVO.artist;

    NSLog(@"ADD DATA MARKER %@", tAnnotation.title);
    if(tAnnotation.audioLocationVORef.state==ANNOTATION_STATE_DROPPING){
     tAnnotation.subtitle = @"Touch submit to Drop";
    }
    [tCover setImage:[tAnnotation.audioLocationVORef.trackVO getCoverArt] forState:UIControlStateNormal];
   }
   // make cover enabled to see song detail?
   tCover.enabled = NO;

   tNewMarkerView.leftCalloutAccessoryView = tCover;

   [tCover release];

  return tNewMarkerView;
 }
 return nil;

}

I tried to delete and add again the graphics as assets. I have been playing around a bit with the frame property. So far no luck.

And why the difference between simulator and device. I am using SDK 4.2... on iPhone 4


Make sure the image filenames match exactly with the resource names including upper/lower-case.

For example, if the resource is "GreenMarker.png", then "greenmarker.png" will only work on the simulator and not on the device.

Apple QA1697 (Why doesn't my device load a file that loads fine in the Simulator?) says:

Case-sensitivity: iPhone OS uses a case-sensitive file system, unlike the Simulator which uses a case-insensitive file system by default. Make sure the case-sensitivity of resources accessed within code matches the filename case-sensitivity.