私は StartMonitoringForRegion を使用する必要があるアプリケーションを持っています。次のコードをアプリケーション didFinishLaunchingWithOptions に入れると、機能します。
[loc startUpdatingLocation];
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(21.456372,39.287972);
CLRegion* region = [[CLRegion alloc] initCircularRegionWithCenter:coord radius:200 identifier:@"C"];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:50];
しかし、別のビューで同じコードを使用すると機能しません!! 次のコードを使用して、メインスレッドでコードを実行しようとしました:
if (![NSThread isMainThread])
{
[self performSelectorOnMainThread:@selector(MonitorRegion:) withObject:pr waitUntilDone:NO];
return;
}
それでもうまくいきません!
コードが didFinishLaunchingWithOptions では機能し、他のビューでは機能しないのはなぜですか!
地域のモニターが機能しない場合はありますか?