私は内容が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];
}