2011-01-21 16 views
0

私はこれを非常に早い段階で動作させていましたが、停止しました。コードは次のとおりです。MKAnnotationはシミュレータのカスタムマーカーグラフィックを表示しますが、デバイスには表示されません

- (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; 

} 

グラフィックを削除してもう一度資産として追加しようとしました。私はフレームのプロパティで少し遊んでいます。今まで運がない。

なぜシミュレータとデバイスの違い?私はSDK 4.2を使用しています... iPhone 4の場合

答えて

3

画像ファイル名が大文字小文字を含むリソース名と正確に一致することを確認してください。

たとえば、リソースが "GreenMarker.png"の場合、 "greenmarker.png"はシミュレータでのみ動作し、デバイスでは動作しません。

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

大文字小文字の区別を:iPhone OSは デフォルトで 、大文字と小文字を区別しないファイルシステムを使用しています シミュレータとは異なり、 大文字と小文字が区別されるファイルシステムを使用しています。 コード内の にアクセスしたリソースの大文字と小文字の区別が、ファイル名 の大文字と小文字を区別していることを確認してください。

+0

それはそうだった。私は約1週間私を怒らせた。トリックは私がmarkerAとmarkerBという名前のものを持っていました。私はそれらを別の州に持っていたので、私はフォルダをチェックしました。名前はmarkeraとmarkerBでした。 3回目のチェックで、ミックスアップがどこにあるのかが分かりました。彼らは実際にシミュレーターを感覚的にするはずです。 – Marcus

+0

これは一日中私に迷惑をかける。それは簡単な命名の問題でした。ありがとうございました!!! – sixstatesaway

1

真実ですが、Macでは大文字と小文字は区別されますが、大文字と小文字は区別されません。シミュレータはMac上で動作しますので、それがあなたのものです。

関連する問題