【发布时间】:2016-08-09 16:23:26
【问题描述】:
我正在尝试使用新的 iOS7 MKMapSnapshotter 来生成静态地图图像。每当我的应用需要地图时,我都会调用以下命令:
MKMapSnapshotter *snapshotter = [[[MKMapSnapshotter alloc] initWithOptions:theOptions] autorelease];
dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
DebugLog(@"Snapshotter allocated %@ and run on queue %@", snapshotter, aQueue);
[snapshotter startWithQueue:aQueue completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
DebugLog(@"Snapshotter completion block %@", snapshotter);
// perform selector on main thread to set self.imageView.image = shanpshot.image;
}
在大多数情况下,这很有效。但是有时,设备似乎因地图请求而过载,然后停止渲染。在我的日志文件中,我将看到关于“已分配快照器”的第一条日志语句,但从未看到“快照器完成块”消息。
有没有可能我的请求永远不会从调度队列中执行? 有人遇到过这个问题吗?
【问题讨论】:
-
您找到解决方案了吗?我面临同样的问题:/
-
你试过使用 - (void)startWithCompletionHandler:(MKMapSnapshotCompletionHandler)completionHandler 吗?
-
我将首先为您的快照程序实例创建一个专用队列。如果问题得到可靠解决,则您可能已在应用中的其他位置阻止了全局后台队列。
标签: ios ios7 mapkit grand-central-dispatch mkmapsnapshotter