2012-01-28 2 views
1

私はちょうど新しいアプリケーションを作成し、私はビューでマップを実装しました。 私はいくつかの個人注釈付きのマップを作成しましたが、ユーザーがピンに触れると何も表示されません。私はピンの色を設定しようとしましたが、何も動作しないようです。私はピンをタッチすると、ユーザーが "ネイティブマップ"を使用するために、ポップアップの開示ボタンに触れることができる必要があります。 ピンに触れると、このピンはより暗くなりますが、それ以外は何も表示されません。 誰かが私を助けることができますか?お願いします!!ポップアップなしのピンでマップキットの新しい注釈

、遠くのapire poiの公開と遠くのapp lre app nativa mappe per creare il percorso!セカイモンが支払と米国内での受取を行い、日本へお届けいたします。非倫理的なネーメモアは、コロンビア、イマジニ、.... ....私はチュートリアルではないガソリンを使用しています!

ヘッダサブクラス

#import <Foundation/Foundation.h> 
    #import <MapKit/Mapkit.h> 

    @interface myAnnotation : NSObject <MKAnnotation>{ 

     CLLocationCoordinate2D coordinate; 
     NSString *titolo; 
     NSString *sottotitolo; 
    } 

    @property(nonatomic,assign) CLLocationCoordinate2D coordinate; 
    @property(nonatomic,copy) NSString *titolo; 
    @property(nonatomic,copy) NSString *sottotitolo; 


    @end 

実装サブクラス

@implementation myAnnotation 

    @synthesize titolo; 
    @synthesize sottotitolo; 
    @synthesize coordinate; 

    -init{ 
     return self; 

    } 

    @end 

ファイル.Mビューコントローラ

CLLocation *userLoc = myMapView.userLocation.location; 
     CLLocationCoordinate2D userCoordinate = userLoc.coordinate; 
     NSLog(@"user latitude = %f",userCoordinate.latitude); 
     NSLog(@"user longitude = %f",userCoordinate.longitude); 
     myMapView.delegate=self; 


     NSMutableArray* annotations=[[NSMutableArray alloc] init]; 

     CLLocationCoordinate2D theCoordinate1; 
     theCoordinate1.latitude = 45.; 
     theCoordinate1.longitude = 7.; 

     CLLocationCoordinate2D theCoordinate2; 
     theCoordinate2.latitude = 45.; 
     theCoordinate2.longitude = 12.; 

     CLLocationCoordinate2D theCoordinate3; 
     theCoordinate3.latitude = 45.; 
     theCoordinate3.longitude = 8.; 

     CLLocationCoordinate2D theCoordinate4; 
     theCoordinate4.latitude = 43.; 
     theCoordinate4.longitude = 7.; 

     myAnnotation* myAnnotation1=[[myAnnotation alloc] init]; 

     myAnnotation1.coordinate=theCoordinate1; 
     [email protected]"xxxx"; 
     [email protected]"xxx"; 


     myAnnotation* myAnnotation2=[[myAnnotation alloc] init]; 

     myAnnotation2.coordinate=theCoordinate2; 
     [email protected]"yyyy"; 
     [email protected]"yyyy"; 

     myAnnotation* myAnnotation3=[[myAnnotation alloc] init]; 

     myAnnotation3.coordinate=theCoordinate3; 
     [email protected]"zzz"; 
     [email protected]"zzz"; 

     myAnnotation* myAnnotation4=[[myAnnotation alloc] init]; 

     myAnnotation4.coordinate=theCoordinate4; 
     [email protected]"kkk"; 
     [email protected]"kkk"; 


     [myMapView addAnnotation:myAnnotation1]; 
     [myMapView addAnnotation:myAnnotation2]; 
     [myMapView addAnnotation:myAnnotation3]; 
     [myMapView addAnnotation:myAnnotation4]; 


     [annotations addObject:myAnnotation1]; 
     [annotations addObject:myAnnotation2]; 
     [annotations addObject:myAnnotation3]; 
     [annotations addObject:myAnnotation4]; 


     NSLog(@"%d",[annotations count]); 

し、このスニペットはピン

を示し、パーソナライズします

答えて

3

MKAnnotationプロトコルでは、クラスがtitlesubtitleに応答する必要があります。プロパティの名前は、まるでそのように指定する必要があります。

同じ名前の別の名前のプロパティを使用することもできますが、マップビューでは呼び出されません(titlesubtitleを探しています)。

viewForAnnotationの開示ボタンでは、rightCalloutAccessoryViewUIButtonに設定し、calloutAccessoryControlTappedデリゲートメソッドでタップに応答します。

このデリゲートメソッドでは、(myAnnotation *)view.annotationを使用してアノテーションオブジェクトにアクセスし、openURLを呼び出してマップアプリケーションを開くことができます。

+0

ありがとうございますアンナカレーナナ!あなたは問題を解決しました! :) – TheInterestedOne

関連する問題