我正在开发一个使用Parse的应用程序,并试图根据位置的类型放置自定义注释图像。
在ViewForAnnotation中,我有以下内容:
CustomStoreAnnotation *ann = (CustomStoreAnnotation *)annotation;
PFQuery* locationQuery = [PFQuery queryWithClassName:@"tbl_location"];
[locationQuery whereKey:@"name" equalTo:ann.title];
[locationQuery findObjectsInBackgroundWithBlock:^(NSArray *locations, NSError *error) {
if (!error)
{
if ([locations count] > 0)
{
//get specific pfobject and set annotation image
}
else
{
//handle empty array
}
}
}];
此代码正在运行,但出现了一种奇怪的行为,即最初错误的图像临时出现在annotationView上,但随后会自行修复。有什么想法吗?
我意识到我根本不需要这个查询,因为在第一次将类型添加到映射时,我可以将它们与每个注释关联起来。这完全避免了查询的需要,从而解决了我的问题。