zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Bootstrap/Font-Awesome/sweetalert插件
    网络编程
    异常处理
    再看属性查找
    元类
    面向对象中的一些内置方法
    反射
    内置函数
    绑定方法与非绑定方法
    多态与鸭子类型
  • 原文地址:https://www.cnblogs.com/tangranyang/p/4655797.html
Copyright © 2011-2022 走看看