新しい CLLocation と CLRegion を設定しようとしていますが、実際の場所に関係なく、場所は常に同じ座標で返されます。メインの UIViewController は、カスタム クラスと同様に、CLLocationManagerDelegate プロトコルに準拠しています。カスタム クラスが初期化されると、タイマーが 0.25 秒後に起動するように設定されます。次のコードを使用します。
mainLocationManager = [[CLLocationManager alloc] init];
[mainLocationManager startUpdatingLocation];
location = [mainLocationManager location];
if (![location.timestamp isEqualToDate:[NSDate dateWithTimeIntervalSinceNow:0]]) { //filters cached data by updating location if cached data not recent enough
location = [mainLocationManager location];
}
//Set up region
region = [[CLRegion alloc] initCircularRegionWithCenter:location.coordinate
radius:500
identifier:[NSString stringWithFormat:@"region:%@", locationName]];
NSLog(@"%@ %@", location, region);
座標が常に同じ値であることを除いて、コードは機能しているように見えます。これを変更する方法がわかりません。どんな助けでも大歓迎です、ありがとう!