ios 区域检测 使用coreLocation

#import "ViewController.h"

#import <CoreLocation/CoreLocation.h>

@interface ViewController ()<CLLocationManagerDelegate>

@property(nonatomic,strong)CLLocationManager *manager;

@end

@implementation ViewController

-(CLLocationManager*)manager

{

if (_manager==nil) {

_manager=[[CLLocationManager alloc]init];

}

return _manager;

}

- (void)viewDidLoad {

[super viewDidLoad];

self.manager.delegate=self;

//判断ios7 或者8

if([[UIDevice currentDevice].systemVersion doubleValue]>8.0)

{

//[self.manager requestWhenInUseAuthorization];

[self.manager requestAlwaysAuthorization];

}

//创建中心点

CLLocationCoordinate2D center=CLLocationCoordinate2DMake(40.058501, 116.304171);

//确定区域

CLCircularRegion *circluar=[[CLCircularRegion alloc]initWithCenter:center radius:500 identifier:@"软件科技园!!"];

[self.manager startMonitoringForRegion:circluar];

}

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region

{

NSLog(@"进入坚挺趋于调用");

}

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region

{

NSLog(@"离开监听区域时调用");

}

@end

上一篇:css3中强大的filter(滤镜)属性


下一篇:UVA Knight Moves