“区域”的数量。由RegionMonitoring监控,根据用户在iOS7中的当前位置 [英] Number of "region" monitored by RegionMonitoring, based on users current location in iOS7

查看:165
本文介绍了“区域”的数量。由RegionMonitoring监控,根据用户在iOS7中的当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展这样一个应用程序执行以下操作的项目:

I am working on such a project where apps do the following things:


  1. 用户选择半径(10米到1000米)然后按开始按钮转到下一个 viewController

  2. 此处应用程序抓取用户当前位置并根据该位置启动区域监控选定半径的当前位置

  3. 如果用户越过某个边界(10米到1000米),则会发出ExitRegion警告消息。并根据用户新的当前位置再次启动区域监控。应用程序一直在做这个,包括前台和后台模式。我设法做到了&它工作得很好。

现在,在这里我监视一个区域,然后再监视另一个区域。所以数字实际上就是一个。但是我知道一个应用程序可以通过区域监控监控的区域的最大数量是15.现在我的问题是在这种情况下我应该处理这个最大数量的区域问题吗?如果是,那么如何?

Now, Here I monitor one region, after that another one. So the number is actually one. But I know the maximum number of regions one apps can monitored by "Region Monitoring" is 15. Now my question is in this case should I handle this maximum number of region issue or not? If yes, then how?

我还想补充一点,它有一些解决方案,只适用于iOS 6及更早版本。所以,请根据用户在iOS7中的当前位置,通过RegionMonitoring监控处理区域数量的解决方案,让我知道。

One more thing I want to add is, there are some solution of it, which is only work for iOS 6 and earlier. So please let me know if there have some solution of handling number of "region" monitored by "RegionMonitoring", based on users current location in iOS7.

这将是一个如果能给出答案或任何建议来完成我的应用程序所需的要求,我将感到非常高兴。

It will be a great pleasure to me if one can give the answer or any suggestion to finish my apps required requirements.

推荐答案

如果您查看文档,最大限制为20.当你超过这个数字时, iOS 将释放对最旧区域的监控(认为它就像一个FIFO队列)。确保半径小于 maximumRegionMonitoringDistance 。换句话说,你不必担心最大限制,你可以通过实现 didStartMonitoringForRegion:委托来确保这一点。

If you check the docs, max limit is 20. When you exceed this number, the iOS will release monitoring of the oldest region (think its like its a FIFO queue). Make sure you keep the radius smaller than maximumRegionMonitoringDistance. So in other words you don't need to worry about max limit, you can make sure this by implementing didStartMonitoringForRegion: delegate.

但是,如果您想控制自己监控的区域数量,您可以随时停止使用 stopMonitoringForRegion监控区域:您可以获取区域列表使用属性 monitoredRegions 进行监控。您可以随时清理不再需要的区域。保持最小化是一种很好的做法,因为它会影响电池和应用程序的性能。

But, If you want to control number of regions being monitored by yourself, you can always stop monitoring a region using stopMonitoringForRegion: You can get a list of regions being monitored with the property monitoredRegions. You can always clear up the region you don't need any more. It's a good practice to keep it minimum as it does effect the battery and app performance.

我正在使用以下代码在需要时清理我的所有区域。

I'm using following code to clear up all my regions when required.

for (CLCircularRegion *region in self.locationManager.monitoredRegions) {
    [self.locationManager stopMonitoringForRegion:region];
}

但在你的情况下,我建议使用一个常量来表示区域标识符(例如MY-REGION),因为您无法监控具有相同标识符的两个区域,因此添加具有相同ID的其他区域会自动删除先前监控的区域。

But in your case, I would suggest using a constant for Region identifier (e.g. "MY-REGION"), as you cannot monitor two regions with same identifier, adding an other region with the same id removes previously monitored region automatically.

CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:coordinate radius:50.0f identifier:@"MY-REGION"];
[self.locationManager startMonitoringForRegion:region];

这篇关于“区域”的数量。由RegionMonitoring监控,根据用户在iOS7中的当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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