0

ユーザーが特定の地域に到達したときに位置情報ベースのリマインダーが欲しい

そのために、私は次のコードを書きました

CLLocationManager *manager=[[CLLocationManager alloc] init];
manager.desiredAccuracy=kCLLocationAccuracyBest;

manager.delegate=self;

CLLocationCoordinate2D loc;

loc.latitude=LReminder.lat;

loc.longitude=LReminder.lon;

CLRegion *region=[[CLRegion alloc] initCircularRegionWithCenter:loc
radius:LReminder.accuracy dentifier:LReminder.title];

CLLocationAccuracy acc=1.0;

[manager startMonitoringForRegion:region desiredAccuracy:acc];

[manager startMonitoringSignificantLocationChanges];

そしてマネージャーデリゲートの場合

-(void)locationManagerCLLocationManager *)manager didEnterRegionCLRegion *)region
{

    NSLog(@"didEnterRegion for %@",region.identifier);

    UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didEnterRegion" 
message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];

    [alr show];

    [alr release];
}

-(void)locationManagerCLLocationManager *)manager didExitRegionCLRegion *)region
{
    NSLog(@"didExitRegion for %@",region.identifier);

    UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didExitRegion" message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];

    [alr show];

    [alr release];
}

問題は、リマインダーの場所に到達したときに、デリゲートのメソッドを呼び出していないことです

私を助けてください

4

1 に答える 1

2

詳細はわかりませんが、推測することしかできませんが、iPhone 4 を使用していないことは間違いありません。現在、領域監視は iPhone 4 でのみ機能します。

以下を使用する必要があります。

[CLLocationManager regionMonitoringEnabled]

デバイスがリージョン モニタリングを使用できるかどうかを判断します。

于 2010-10-15T20:15:09.407 に答える