내용이 json 배열로 생성 된 테이블 뷰가 있습니다. 또한 사용자의 위치가 변경 될 때 위치 서비스를 사용하기 때문에 사용자의 위치를 기준으로 테이블 데이터의 변경 사항을 반영하도록 테이블이 다시로드됩니다.MBProgressHUD 조건부 실행
내 문제는 뷰로드 시작 부분에 활동 표시기를 표시하지만 위치 업데이트 및 테이블 재로드마다 표시기가 표시됩니다. 이는 매우 짧은 간격으로 이루어 지므로 응용 프로그램이 중단됩니다.
초기로드가 아니고 위치 변경으로 인해 다시로드되는 경우 MBProgressHUD가 표시되지 않도록 다음 코드에 조건을 입력 할 수 있습니까?
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
return [rows count];
}
이 다시로드가 수행되는 경우입니다 :
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSString *lat = [NSString stringWithFormat:@"%f", newLocation.coordinate.latitude];
NSString *longt = [NSString stringWithFormat:@"%f", newLocation.coordinate.longitude];
//CGFloat Alat = [lat floatValue];
//CGFloat Alon = [longt floatValue];
self.aalat = lat;
self.aalon = longt;
// NSLog(@"anlat: %@", aalat);
// NSLog(@"anlong: %@", aalon);
[[NSUserDefaults standardUserDefaults] setObject:aalat forKey:@"latitude"];
[[NSUserDefaults standardUserDefaults] setObject:aalon forKey:@"longitude"];
[tableview reloadData];
}