2012-03-08 18 views
1

マップ上に2つのピンを配置しましたが、それぞれクリックすると注釈が付きますが、StoreLocationOneの注釈のみが表示されます。マップ上の両方のピンが表示されていますが、クリックするとStoreLocationTwo注釈が表示されません。MapKitピンの注釈が表示されない

-(void)viewDidLoad { 
    [super viewDidLoad]; 

    [mapview setMapType:MKMapTypeStandard]; 
    [mapview setZoomEnabled:YES]; 
    [mapview setScrollEnabled:YES]; 

    MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } }; 
    region.center.latitude = 57.132053; 
    region.center.longitude = -2.135592; 
    region.span.longitudeDelta = 0.01f; 
    region.span.latitudeDelta = 0.01f; 
    [mapview setRegion:region animated:YES]; 

    StoreLocationOne *ann = [[StoreLocationOne alloc] init]; 
    ann.title = @"Heavenly Pizzas Mannofield"; 
    ann.subtitle = @"483a Great Western Rd, Aberdeen, AB10 6NN"; 
    ann.coordinate = region.center; 
    [mapview addAnnotation:ann]; 

    MKCoordinateRegion region2 = { {0.0, 0.0 }, {0.0, 0.0 } }; 
    region2.center.latitude = 57.232458; 
    region2.center.longitude = -2.347853; 
    region2.span.longitudeDelta = 0.01f; 
    region2.span.latitudeDelta = 0.01f; 

    StoreLocationTwo *ann2 = [[StoreLocationTwo alloc] init]; 
    ann2.title2 = @"Heavenly Pizzas Kintore"; 
    ann2.subtitle2 = @"School Road, Kintore, AB51 0UU"; 
    ann2.coordinate = region2.center; 
    [mapview addAnnotation:ann2]; 

} 

答えて

1

titlesubtitleプロパティは、その正確に名前を付ける必要があります。マップビューでは、title2subtitle2を探すことはできません。

MKAnnotationを実装する複数のクラスを持つことができますが、プロパティ名はプロトコルと同じでなければなりません。あなたが必要とするすべてのプロパティがある場合

また、coordinatetitle、およびsubtitleは、あなたが使用できるビルトインのアノテーションクラスMKPointAnnotationの代わりに、各座標に別々のクラスを作成します。

関連する問題