2012-07-05 66 views
2

我添加多个批注程序是这样的:MKAnnotation显示所有引脚标题不点击

- (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];  
    } 
} 

是否有可能显示标题为所有引脚没有点击它们?

回答

-3

没有它不可能。您必须点击注释以显示标题。

0

U可以使用自定义注释视图来显示Title和subTitle,而无需单击pin。 有一个自定义注释视图的教程。

This app contains the custom annotation view

+0

链接中的答案是死 - *对不起,该页面无法找到* – Pang 2017-09-25 05:55:27

3

试试这个。它会自动显示标题。

-(void)mapView:(MKMapView *)mapView1 didAddAnnotationViews:(NSArray *)views 
{ 
    [self.mapView selectAnnotation:yourannotationpin animated:NO]; 
} 
7

声明数组来存储所有的注释和使用的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]; 
}