Saturday, 31 August 2013

Screen doesn't update until segmented control value chanee ends

Screen doesn't update until segmented control value chanee ends

My first program using map kit ios 6. I have 6000 annotations to add to a
map and it takes about 7 seconds to load. i want to put a window up to say
loading. works but the loading screen does not come until it
segmentedcontolvaluechange ends. not sure how to update my view when i
call the MBProgressHUD routine.
- (IBAction)myanscSegmentedControlValueChange:(id)sender {
int lvalue;
int hvalue;
switch (myanscSegmentedControl.selectedSegmentIndex) {
case 0:
lvalue=0;
hvalue=999999;
break;
case 1:
lvalue=1;
hvalue=999999;
break;
case 2:
lvalue=1;
hvalue=500;
break;
case 3:
lvalue=501;
hvalue=1000;
break;
case 4:
lvalue=1000;
hvalue=999999;
break;
default:
break;
}
[self.myMKMapView removeAnnotations:myMKMapView.annotations];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Loading Data..";
for (Customer *row in self.importedRows) {
if ([row.anscvalue integerValue]>=lvalue & [row.anscvalue
integerValue]<=hvalue) {
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = [row.lat doubleValue];
annotationCoord.longitude =[row.lon doubleValue];
MKPointAnnotation *annotationPoint = [[MKPointAnnotation
alloc] init];
annotationPoint.coordinate = annotationCoord;
annotationPoint.title = row.title ;
annotationPoint.subtitle = row.subtitle;
[myMKMapView addAnnotation:annotationPoint];
}
}
MBProgressHUD hideHUDForView:self.view animated:YES];
}

No comments:

Post a Comment