2010-12-22 13 views
1

現在、私はNSXMLParserを処理しているXMLモデルを持っています。私は処理後に私のモデルで約340のオブジェクトを取得します。すべてのオブジェクトをMKMapViewに配置します。ユーザがオブジェクトを「選択」すると(MKAnnotationViewPin);いったん始めたら、タイトルにもコーズンが表示されますが、サブタイトルはプレースホルダーに設定されています。追加の情報を取得するために別のXMLファイルを処理します。サブタイトルは更新され、読み込まれます。MKAnnotationViewのサブタイトルがリロードされない

XMLファイルが解析されると、変更されたサブタイトルを反映するように通知され、<MKAnnotation>オブジェクトが更新されます。地図上の変化を反映させるためには、ピンを「選択解除」して、それを再度クリックして変更を表示する必要があります。ここで

<MKAnnotation>オブジェクトされています

ヘッダー:

@interface CPCustomMapPin : NSObject <MKAnnotation> 
{ 
    NSString *_title; 
    NSString *_annotation; 
    CLLocationCoordinate2D _coords; 
    NSString *stationID; 
} 

@property (nonatomic, retain) NSString *_title; 
@property (nonatomic, retain) NSString *_annotation; 
@property (nonatomic) CLLocationCoordinate2D _coords; 
@property (nonatomic, retain) NSString *stationID; 

- (id) initWithTitle: (NSString *) _title withAnnotation: (NSString *) _annotation withCoords: (CLLocationCoordinate2D) _coords withStationID: (NSString *) _id; 

実装:

@implementation CPCustomMapPin 

@synthesize _title, _annotation, _coords, stationID; 

- (id) initWithTitle: (NSString *) __title withAnnotation: (NSString *) __annotation withCoords: (CLLocationCoordinate2D) __coords withStationID: (NSString *) _id 
{ 
    _title = [[NSString alloc] init]; 
    _annotation = [[NSString alloc] init]; 
    stationID = [[NSString alloc] init]; 

    [self set_title: __title]; 
    [self set_annotation: __annotation]; 
    [self set_coords: __coords]; 
    [self setStationID: _id]; 

    return self; 
} 

- (NSString *) title 
{ 
    return _title; 
} 

- (NSString *) subtitle 
{ 
    return _annotation; 
} 

- (CLLocationCoordinate2D) coordinate 
{ 
    return _coords; 
} 

- (NSString *) description 
{ 
    return [NSString stringWithFormat: @"title: %@ subtitle: %@ id: %@", _title, _annotation, stationID]; 
} 

- (void) dealloc 
{ 
    [_title release]; 
    [_annotation release]; 
    [stationID release]; 

    [super dealloc]; 
} 

@end 

は、あなたの貴重な入力いただきありがとうございます。誰も知らない

答えて

2

はどうやら...私はこのテクニックを見つけた:

- (void) closeAnnotation: (id <MKAnnotation>) annotation inMapView: (MKMapView *) mapView 
{ 
    [mapView deselectAnnotation: annotation animated: NO]; 
    [mapView selectAnnotation: annotation animated: YES]; 
} 

そしてもちろん、あなたがそれに応じてメソッドを呼び出します。

例:

- (void) myMethod 
{ 
    for (id <MKAnnotation> _annotation in mapView.annotations) 
    { 
     [self closeAnnotation: _annotation inMapView: mapView]; 
    } 
} 
関連する問題