0
我有一個從plist中加載的字典。我重複我的數組,其中包含總計4000長和拉特。添加MapKit Overlay來映射x1一次從for循環
我使用GCD在後臺線程上處理for循環(因爲它在處理時鎖定UI)並在此任務中添加疊加層,如下所示。
所有的工作都正常,除了所有疊加層添加到地圖之後纔會出現在整個數組循環結束之後。如果我願意遍歷數組並一次向視圖添加x1覆蓋而不是等待總數進行處理,那麼我會。
-(void)loadOverlays{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Add code here to do background processing
int d;
for (d = 0; d < [[tempDict allValues]count]; d++) {
//Get values from dic
values = [tempDict allValues];
id aValue = [values objectAtIndex:d];
latCircle = [aValue objectAtIndex:1];
lngCircle = [aValue objectAtIndex:2];
geoFCenter = CLLocationCoordinate2DMake([latCircle floatValue], [lngCircle floatValue]);
geoFRadius = 10000.0; // 10,000 metres
//Add Zone circle
circle = [MKCircle circleWithCenterCoordinate:geoFCenter radius:geoFRadius];
[circle setTitle:@"2"];
[self.dragMap addOverlay:circle];
}
});
}
你的權利我總是這麼簡單。不錯的一個歡呼聲。 –
很高興幫助(我們每天都會犯這樣的小錯誤!)。 – garrettmurray
謝謝你的幫忙! –