iOS MapView仅添加第一个注释



我有一个名为allposts的数组,其中有4个对象。当我运行下面的循环时,只有第一个注释被放在映射上。我打印出每个"点"的纬度和经度,它们确实不同,所以我不确定发生了什么

for (PFObject *post in _allPosts)
{
       NSLog(@"NEWANNOTATION");
       PFGeoPoint *point = [post objectForKey:@"Location"];
       NSLog(@"lat: %f  long: %f", point.latitude, point.longitude);
       CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(point.latitude, point.longitude);
       CCBAnnotation *annotation = [[CCBAnnotation alloc] initWithCoordinate:coordinate];
       [self.mapView addAnnotation:annotation];
}

执行此操作后,您还应该检查mapView.annotations,以确定这是添加问题还是显示问题。

最新更新