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];
}
'IPHONE' 카테고리의 다른 글
로컬 알림 사용하기 예제 코드 (0) | 2013.12.19 |
---|---|
MKMapView 에 MKPointAnnotation 추가 하기. (0) | 2013.12.19 |
CLLocationManager 상태 체크 예제 코드 (0) | 2013.12.18 |
String Format Specifiers (0) | 2013.12.17 |
core data 고유키 값 생성. (0) | 2013.12.11 |