私はCLLocationManager
アプリを持っています。したがって、ユーザーが現在の場所を許可または拒否したかどうかを知る方法が必要です。ユーザーによると、TableController は特定の方法でテーブルに値を追加します。入ろうとしましたが、許可または拒否を選択[sightsTableView reloadData];
し
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
た後、テーブルビューがリロードされません。Apple の CLLocation リファレンスを調べたところ、役に立つものが見つかりませんでした。UPD:ここにコードサンプルがあります。
- (void)viewDidLoad {
super viewDidLoad];
[[self locationManager] startUpdatingLocation];
[tempTableView reloadData];
}
- (CLLocationManager *)locationManager {
if (locationManager != nil) {
return locationManager;
}
locationManager = [[CLLocationManager alloc] init];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager setDelegate:self];
return locationManager;
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(@"User allow get location");
self.locationError = NO;
[tempTableView reloadData];
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(@"User declined get location");
self.locationError = YES;
[tempTableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
.... some big code about a sells )...
cell.textLabel.text = array.title;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if(self.locationError == NO){
cell.detailTextLabel.text = @"!";
}
return cell;
}
UPDATE : 実際にはリロードに問題はありません。テーブルビューの更新に問題があることがわかりました。テーブルのスクロールを開始すると、セルに新しい値が表示されます。
2 回目の更新
現在、テーブルが更新されています。問題は、私がどのように電話したかでしUITableView
た。を使用[tempTableView reloadData];
しましたが、うまくいかなかったので、これを使用しようとしましたが、[self.tableView reloadData];
値をリロードしてリフレッシュしています。