6.区域监听

@interface ViewController()

@property(nonatomic,strong)CLLocationManager* manager;

@end

@implementationViewController

- (void)viewDidLoad {

[superviewDidLoad];

// Do any additional setup after loading the view, typically from a

nib.

CLLocationManager*

manager = [[CLLocationManageralloc]init];

manager.delegate=self;

self.manager= manager;

//请求用户授权

//[_manager requestWhenInUseAuthorization];//这个不能实现区域监听

[_manager requestAlwaysAuthorization];

[_manager startUpdatingLocation];

NSLog(@"is = %i",[CLLocationManagerisMonitoringAvailableForClass:[CLCircularRegionclass]]);

CLLocationCoordinate2D center =CLLocationCoordinate2DMake(21.123,121.345);

CLCircularRegion*

region = [[CLCircularRegion alloc]initWithCenter:center radius:1000 identifier:@"lyb"];

[_manager startMonitoringForRegion:region];//开始监听

}

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

NSLog(@"%s",__func__);

}

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

NSLog(@"%s",__func__);

}

@end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 简介 在移动互联网时代,移动app能解决用户的很多生活琐事,比如 周边:找餐馆、找KTV、找电影院等等 导航:根据...
    JonesCxy阅读 5,173评论 1 1
  • 片头曲 CoreLocation框架 来自520it.com 一. iOS8.0之前的定位(✨✨✨✨✨) 1. 前...
    人生路02阅读 2,744评论 0 1
  • CoreLocation框架 一. iOS8.0之前的定位 1. 前台定位 导入CoreLocation框架以及对...
    iOS_Cqlee阅读 5,164评论 1 2
  • CoreLocation框架 一. iOS8.0之前的定位(✨✨✨✨✨) 1. 前台定位 导入CoreLocati...
    Jack__yang阅读 1,580评论 0 4
  • 哪怕我要接受你会离开我这样的现实 我也要尽最大的努力 用最好的状态接受它。
    SweetCC阅读 775评论 0 0

友情链接更多精彩内容