我想使用新的iOS7 MKMapSnapshotter來生成靜態地圖圖像。每當我的應用程序需要的地圖,我把以下內容:iOS MKMapShapshotter完成塊並不總是被稱爲
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;
}
在大多數情況下,這是偉大的工作。然而有時候,設備似乎會因地圖請求而過載,然後停止渲染。在我的日誌文件中,我將看到關於「Snapshotter分配」的第一條日誌語句,但從未看到「Snapshotter completion block」消息。
是否有可能我的請求永遠不會從調度隊列中執行? 有沒有人有過這個問題?
您是否找到解決方案?我正面臨同樣的問題:/ –
你試過用 - (void)startWithCompletionHandler:(MKMapSnapshotCompletionHandler)completionHandler? –
我將首先爲您的快照員實例創建一個專用隊列。如果可靠地解決,您可能已經阻止了全局背景隊列在您應用程序的其他位置。 – nzeltzer