Row*_* Po 5 mkannotation mkannotationview ios
我正在以编程方式添加多个注释,如下所示:
- (void)addAnnotations{
NSInteger i;
CLLocationCoordinate2D location;
for ( i = 0 ; i < [storeLatitude count] ; i ++ ){
location.latitude = [[storeLatitude objectAtIndex:i] floatValue];
location.longitude = [[storeLongitude objectAtIndex:i] floatValue];
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:[listOfStores objectAtIndex:i] andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
[newAnnotation release];
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以在不点击它们的情况下显示所有引脚的标题?
声明一个数组来存储所有注释并使用MKMapView的setSelectedAnnotations:(NSArray*)方法
- (void)addAnnotations {
NSMutableArray *annotationArray = [[NSMutableArray alloc]init];
NSInteger i;
CLLocationCoordinate2D location;
for ( i = 0 ; i < [storeLatitude count] ; i ++ ) {
location.latitude = [[storeLatitude objectAtIndex:i] floatValue];
location.longitude = [[storeLongitude objectAtIndex:i] floatValue];
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle: [listOfStores objectAtIndex:i] andCoordinate:location];
[annotationArray addObject:newAnnotation];
[self.mapView addAnnotation:newAnnotation];
}
[mapView setSelectedAnnotations:annotationArray];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3447 次 |
| 最近记录: |