iOS 5区域监控:可以根据用户当前的coreLocation坐标创建新区域吗? [英] iOS 5 Region Monitoring: Can new regions be created based on users current coordinates from coreLocation?

查看:117
本文介绍了iOS 5区域监控:可以根据用户当前的coreLocation坐标创建新区域吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于在iOS中创建regionMonitoring的区域5.是否可以根据应用程序当前位置的用户创建新区域?或者是否需要开发人员在应用程序二进制文件中预定义所有区域?

我知道你可以根据用户当前的位置注册某些区域,因为os限制了手机/应用可以监控的区域数量有一次,你应该只注册用户当前位置附近的区域......但是可以根据用户的位置即时创建一个区域(以前未定义)?



用例示例:

用户应用程序旋转coreLocation以获得一组精确的坐标,一旦我们有准确的坐标,核心位置就会关闭以节省电量。当用户离开该区域时需要发生事件,所以我们想知道用户何时移动x个距离单位。可以在此用户当前位置周围创建x个距离单位的区域,因此我们可以开始监控退出区域吗?

我进行了大量的研究,但找不到答案......但不幸的是,我对regionMonitoring不是很熟悉。



感谢:)

解决方案

理论上,您可以随时监控任何区域,这些区域不会需要预先定义,您可以使用以下代码实用地创建和监控您所需的区域,

  CLLocationCoordinate2D center = CLLocationCoordinate2DMake(location。 coordinate.latitude,location.coordinate.longitude); 
CLRegion * region = [[CLRegion alloc] initCircularRegionWithCenter:center radius:50.0f identifier:identifier];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyBest];

PS:区域监控实现并不像Apple广告那么有用,我的理解依赖于cell更改事件(再次保存电池)。即使iPhone 4和4s上的默认提醒应用程序(基于位置的提醒)的结果,我也不高兴。


My question is regarding the creation of regions for regionMonitoring in iOS 5. Can new regions be created based on user of the app's current location? Or do all regions need to be predefined by the developer in the applications binary?

I know you can have certain regions register based on the users current location, because the os puts a limit on the number of regions that the phone/app can be monitoring at one time, and you should only register the regions within close proximity to the users current location... but can a region (previously undefined) be created on the fly based on the users location?

use case example:

users app spins up coreLocation to get an accurate set of coordinates, once we have accurate coords, corelocation shuts down to save battery. An event needs to occur when the user leaves the area so we want to know when the user moves x units of distance. Can a region be created x units of distance around this users current location, so we can start monitoring for did exit region?

I put in a good amount of research but could not find an answer... and unfortunately I am not very familiar with regionMonitoring.

Thanks :)

解决方案

Theoretically, You can monitor any region any time, these regions don't need to be predefined, you may use following code to create and monitor your required regions pragmatically,

CLLocationCoordinate2D center = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude);
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:center radius:50.0f identifier:identifier];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyBest];

PS: Region monitoring implementation is not as much useful as apple advertise, to my understanding it relies on cell change events (again to save the battery). I'm not happy even with the results of default Reminders app (location based reminders) both on iPhone 4 and 4s.

这篇关于iOS 5区域监控:可以根据用户当前的coreLocation坐标创建新区域吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆