Limit to 10 number of annotations in mapkit
I have all my annotations(as nsdictionnaries) in an array , and the users add them one by one by tapping on an icon. I want to make it impossible to add more annotations after adding 10 annotations (there is 110).
Is it here i have to make something?:
-(IBAction) plusButtonTapped: (id) sender {
NSDictionary *poiDict = [poiArray objectAtIndex:nextPoiIndex++];
CLLocationCoordinate2D poiCoordinate;
poiCoordinate.latitude = [[poiDict valueForKey:@"workingCoordinate.latitude"] doubleValue];
poiCoordinate.longitude = [[poiDict valueForKey:@"work开发者_运维知识库ingCoordinate.longitude"] doubleValue];
MyMapAnnotation *poiAnnotation = [[MyMapAnnotation alloc]
initWithCoordinate:poiCoordinate
title:[poiDict valueForKey:@"Subtitle"]
color:MKPinAnnotationColorRed ];
[mapView addAnnotation:poiAnnotation];
[self adjustMapZoom];
}
Thank you for your help in advance,
teddafan
Use a mutable array of annotations. Check the length when the button is clicked or disable the button when over your threshhold.
精彩评论