From 4cb82ae7564d6a32d952ccd25eae3c19dc676ec6 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 10 Aug 2015 14:46:41 +0800 Subject: [PATCH] fix setRegion of Map --- Yep/Caches/ImageCache.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Yep/Caches/ImageCache.swift b/Yep/Caches/ImageCache.swift index 01e6ee39..9c1352ff 100644 --- a/Yep/Caches/ImageCache.swift +++ b/Yep/Caches/ImageCache.swift @@ -156,8 +156,8 @@ class ImageCache { let fileName = message.localAttachmentName - let latitude = coordinate.latitude - let longitude = coordinate.longitude + let latitude: CLLocationDegrees = abs(coordinate.latitude) > 90 ? 0 : coordinate.latitude + let longitude:CLLocationDegrees = abs(coordinate.longitude) > 180 ? 0 : coordinate.longitude dispatch_async(self.cacheQueue) { @@ -187,6 +187,7 @@ class ImageCache { options.size = size let locationCoordinate = CLLocationCoordinate2DMake(latitude, longitude) + // 注意上面已保证 latitude: (-90, 90), longitude: (-180, 180),不然 setRegion 会崩溃 options.region = MKCoordinateRegionMakeWithDistance(locationCoordinate, 500, 500) let mapSnapshotter = MKMapSnapshotter(options: options)