Hee all,處理來自XML提要的註釋
此刻,我正在從(有效)XML提要中讀取位置。
<locations>
<location>
<title>Supercoop</title>
<category>supermarkt</category>
<adres>Something</adres>
<latitude>52.8982342</latitude>
<longitude>5.2449449</longitude>
</location>
<location>
<title>Thuis</title>
<category>home</category>
<adres>Something</adres>
<latitude>52.223482</latitude>
<longitude>5.248282</longitude>
</location>
</locations>
我用TouchXML的分析和工作正常「在這個例子中,沒有真實的數據。」
我的問題是:什麼是這種信息處理MKAnnotation的首選方式。
我想過要製作一個對象,例如:MyLocation並將其存儲在那裏,但比我必須走過很多MyLocation對象。
其次,我希望當我使用「calloutAccessoryControlTapped」方法時可以訪問對象/註釋,這樣我可以訪問比存儲在註釋中的更多信息,例如它轉到detailview時。
我希望並且認爲你們可以幫助我! 謝謝!
羅爾夫
好了感謝。我創建了一個MyLocation對象。 而在我的循環中,我創建一個對象並將其添加到地圖。我有以下方法在我的對象: 「 - (id)initWithTitle :(NSString *)標題subTitle:(NSString *)subTitle分類:(NSString *)貓座標:(CLLocationCoordinate2D)coord」 但我想將更多數據存儲在該對象中以供以後在循環之外使用。並且註解需要有一個不同的圖像,我通過添加到對象的分類來定位。 –
對於圖像我可以使用這個委託方法:「 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)註釋」我猜?但是,比我需要一個如果每種註釋? –
這取決於您的圖像的邏輯是什麼。您可以將圖像屬性添加到註釋對象,並在創建註釋時將其設置,並在viewForAnnotation中將annView.image設置爲它,或者可以使用基於其他註釋屬性(如標題,類別)的條件確定要在viewForAnnotation中使用的圖像,ID#等 – Anna