単純な反復子を使用してすべての注釈 (日付で並べ替え) をすばやく循環するための次/前のボタンを作成するために、マップに表示される注釈の配列を並べ替えたいと思います。
私が見る限り、ストア[ワールドマップ注釈]として使用される注釈配列は可変ではないため、並べ替えることができません。以下を試して、注釈配列の一時コピーを作成し、日付で並べ替えて、再度添付しました。
( worldmapは私の MKMapView オブジェクトです)
//COPY
NSMutableArray *annotationSort = [[NSMutableArray alloc]initWithArray:[worldmap annotations]];
//SORT
[annotationSort sortedArrayUsingComparator:^NSComparisonResult(EventPin* obj1, EventPin* obj2) {
return [obj1.eventItemObject.eventDateBegin compare: obj2.eventItemObject.eventDateBegin];
}];
//ADDED SORTED ARRAY
[worldmap removeAnnotations:[worldmap annotations]];
[worldmap addAnnotations:annotationSort];
これはうまくいかないようです。MKMapKit 注釈配列をどのように並べ替えることができますか?