• 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

  • 相关阅读:
    从淘宝数据结构来看电子商务中商品属性设计
    YY淘宝商品数据库设计
    ElasticSearch-聚合bucket学习
    ElasticSearch-聚合bucket
    Elasticsearch(9) --- 聚合查询(Bucket聚合)
    Elasticsearch-多字段搜索(Multifield Search)和提高精确度
    五、设备管理与文件系统
    六、YUM仓库
    四、查找命令
    二、用户权限
  • 原文地址:https://www.cnblogs.com/tangranyang/p/4655797.html
Copyright © 2020-2023  润新知