2010-12-22 9 views
1

В настоящее время у меня есть XML-модель, обрабатывающая мой NSXMLParser; После обработки я получаю около 340 объектов в моей модели. Я помещаю все объекты в свой MKMapView. Когда пользователь «выбирает» объект (MKAnnotationViewPin); Как только я начну, заголовок заполняется, также и коорды (duh?), но субтитры устанавливаются на место. Я обрабатываю другой файл 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]; 
    } 
} 
Смежные вопросы