【发布时间】:2015-01-15 22:21:32
【问题描述】:
我已经从 Parses 后端查询了一组 NSData 对象(转换后将变成图像),如下所示:
var query = PFUser.query()
query.whereKey("location", nearGeoPoint:geopoint)
query.findObjectsInBackgroundWithBlock({ (objects: [AnyObject]!, error: NSError!) -> Void in
for object in objects {
var user:PFUser = object as PFUser
var otherUserImages = [NSData]()
otherUserImages.append(user["image"] as NSData)
}
})
我现在有一个 NSData 对象数组,我想将它们用作图像作为地图上的注释。
所以我创建了一个函数:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
var view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pin")
for userImage in self.otherUserImages {
view.canShowCallout = true
var dataImage = UIImage(data: userImage)
var userMapImage = UIImageView(image: dataImage)
view.leftCalloutAccessoryView = userMapImage
}
}
现在这会将图像作为注释放置但仅在array[0] 我似乎无法将所有图像作为注释?
谁能告诉我我错过了什么?
【问题讨论】:
标签: arrays swift parse-platform