반응형

CLLocationCoordinate2D regionCords = CLLocationCoordinate2DMake(37.78, -122.408);
    // @property (strong, nonatomic) CLRegion *boundary;
    boundary = [[CLRegion alloc] initCircularRegionWithCenter:regionCords radius:1000.0f identifier:@"San Francisco"];


// @property (strong, nonatomic) CLLocationManager *locMgr;

    locMgr = [[CLLocationManager alloc] init];
    locMgr.desiredAccuracy = kCLLocationAccuracyBest;
    locMgr.distanceFilter = 1000.0f;
    locMgr.delegate = self;
    
    if ([CLLocationManager locationServicesEnabled] == FALSE)
    {
        message = @"Location cannot be initialized. Please check settings";
        
        [locMgr startUpdatingLocation];
    }
    else
    {
        [locMgr startUpdatingLocation];
        
        [locMgr startMonitoringForRegion:boundary];
    }


// 델리 게이트 처리.

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You Entered San Francisco" message:@"Welcome to San Francisco" delegate:self
                                          cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
   
    [alert show];
}

반응형
Posted by 컴스터
,