2011-11-28 63 views

回答

1

有關的MKMapView排序註釋我用didAddAnnotationViews回調:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { 
     for (MKAnnotationView * annView in views) { 
     if ([annView.annotations isTop]) { 
      [[annView superview] bringSubviewToFront:annView]; 
     } else {   
      [[annView superview] sendSubviewToBack:annView]; 
     } 
    }  
} 
1

嘗試這樣的事情,

NSArray *sortedArray = [mapView.annotations sortedArrayUsingComparator:<#^NSComparisonResult(id obj1, id obj2)cmptr#>]; 

基本上mapView.annotations會給你在你的NSArray所有註釋的訪問,然後使用sortedArray ...方法(there are lots of different one),這將有助於您整理註釋數組並返回新的排序NSArry。

希望這是你在問什麼,

乾杯