首页 > 移动平台 > 详细

ios 区域检测 使用coreLocation

时间:2015-07-17 22:18:30      阅读:321      评论:0      收藏:0      [点我收藏+]

#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

ios 区域检测 使用coreLocation

原文:http://www.cnblogs.com/tangranyang/p/4655797.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!