下面有快速密码。地图上的一切都如预期的那样工作,但我从未看到任何RMTileCashBackgroundDelegate方法正在被调用。我看到的就是“缓存开始了!”然后什么都没有。我试过很多次调整,但都没能成功。任何帮助都将不胜感激!
class MapboxViewController: UIViewController, RMMapViewDelegate, RMTileCacheBackgroundDelegate {
var mapView: RMMapView!
override func viewDidLoad() {
super.viewDidLoad()
let mapSource:RMMapboxSource = RMMapboxSource(mapID: "myMapId")
mapView = RMMapView(frame: self.view.bounds, andTilesource: mapSource)
mapView.delegate = self
//background caching
mapView.tileCache.backgroundCacheDelegate = self
mapView.tileCache.beginBackgroundCacheForTileSource(mapView.tileSource, southWest: swBounds, northEast: neBounds, minZoom: 13, maxZoom: 17)
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
mainView.addSubview(mapView)
}
func tileCache(tileCache: RMTileCache!, didBeginBackgroundCacheWithCount tileCount: Int, forTileSource tileSource: RMTileSource) {
println("Caching started!")
}
func tileCache(tileCache: RMTileCache!, didBackgroundCacheTile tile: RMTile, withIndex tileIndex: Int, ofTotalTileCount totalTileCount: Int) {
println("Cached tile \(tileIndex) of \(totalTileCount)")
}
func tileCache(tileCache: RMTileCache!, didReceiveError error: NSError!, whenCachingTile tile: RMTile) {
println("Error caching tile")
}
func tileCacheDidCancelBackgroundCache(tileCache: RMTileCache!) {
println("Caching cancelled!")
}
func tileCacheDidFinishBackgroundCache(tileCache: RMTileCache!) {
println("Caching complete!")
}
}发布于 2015-04-25 05:04:00
这里有两个问题,其中一个问题在上面的代码中并不明显:
感谢Mapbox支持他们的帮助。下面是Swift中一个很好的离线缓存示例,以供参考:https://github.com/mapbox/mapbox-ios-sdk-offline
https://stackoverflow.com/questions/29200050
复制相似问题