
- (voID)updateUnits { PFquery *query = [PFquery queryWithClassname:@"devices"]; [query whereKeyExists:@"location"]; [query findobjectsInBackgrounDWithBlock:^(NSArray *objects,NSError *error) { if (!error) { for (PFObject *row in objects) { PFGeoPoint *geoPoint = [row objectForKey:@"location"]; CLLocationCoordinate2D coord = { geoPoint.latitude,geoPoint.longitude }; for (ID<MKAnnotation> ann in mapVIEw.annotations) { if ([ann.Title isEqualToString:[row objectForKey:@"deviceid"]]) { [ann setCoordinate:coord]; NSLog(@"latitude is: %f",coord.latitude); NSLog(@"Is called"); break; } else { //[self.mapVIEw removeAnnotation:ann]; } } } } else { } }];}解决方法 更新(以反映解决方案): 拥有自己的自定义注释并实现setCoordinate和/或合成坐标可能会导致问题.
资料来源:http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html
以前的方案:
您只需删除所有注释,然后重新添加它们即可.
[mapVIEw removeAnnotations:[mapVIEw.annotations]];[mapVIEw addAnnotations:(NSArray *)];
或删除它们并逐个重新添加:
for (ID<MKAnnotation> annotation in mapVIEw.annotations){ [mapVIEw removeAnnotation:annotation]; // change coordinates etc [mapVIEw addAnnotation:annotation]; } 总结 以上是内存溢出为你收集整理的iOS刷新mapview上的注释全部内容,希望文章能够帮你解决iOS刷新mapview上的注释所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)