cache mapImage in FeedView

This commit is contained in:
nixzhu
2015-11-30 16:23:20 +08:00
parent e776799112
commit 8508a03e51
2 changed files with 3 additions and 45 deletions
@@ -336,30 +336,6 @@ class FeedSocialWorkCell: FeedBasicCell {
self?.locationMapImageView.image = image
})
/*
let options = MKMapSnapshotOptions()
options.scale = UIScreen.mainScreen().scale
let size = CGSize(width: UIScreen.mainScreen().bounds.width - 65 - 60, height: 110 - locationNameLabel.bounds.height)
options.size = size
options.region = MKCoordinateRegionMakeWithDistance(locationCoordinate, 500, 500)
let mapSnapshotter = MKMapSnapshotter(options: options)
mapSnapshotter.startWithCompletionHandler { (snapshot, error) -> Void in
if error == nil {
guard let snapshot = snapshot else {
return
}
let image = snapshot.image
dispatch_async(dispatch_get_main_queue()) { [weak self] in
self?.locationMapImageView.image = image
}
}
}*/
locationNameLabel.text = locationInfo.name
}
}
+3 -21
View File
@@ -421,28 +421,10 @@ class FeedView: UIView {
if let locationCoordinate = feed.locationCoordinate {
let options = MKMapSnapshotOptions()
options.scale = UIScreen.mainScreen().scale
let size = CGSize(width: UIScreen.mainScreen().bounds.width - 65 - 60, height: 80 - locationNameLabel.bounds.height)
options.size = size
options.region = MKCoordinateRegionMakeWithDistance(locationCoordinate, 500, 500)
let mapSnapshotter = MKMapSnapshotter(options: options)
mapSnapshotter.startWithCompletionHandler { (snapshot, error) -> Void in
if error == nil {
guard let snapshot = snapshot else {
return
}
let image = snapshot.image
dispatch_async(dispatch_get_main_queue()) { [weak self] in
self?.locationMapImageView.image = image
}
}
}
ImageCache.sharedInstance.mapImageOfLocationCoordinate(locationCoordinate, withSize: size, completion: { [weak self] image in
self?.locationMapImageView.image = image
})
}
locationNameLabel.text = feed.locationName