简体   繁体   English

iOS 6自动暂停不起作用

[英]iOS 6 AutoPause doesn't work

I've follow the example of AutoPause from " Session 303 - Staying on track from Location Services " WWDC 2012 WWDC 2012的“ 会议303-跟踪位置服务的进度”中了解自动暂停的示例

In the example you can see how AutoPause is enabled and there two methods which are called: 在示例中,您可以看到如何启用“自动暂停”,并且有两种方法被称为:

-(void) locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager
-(void) locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager

I've done the same example but these methods aren't never called. 我已经完成了相同的示例,但从未调用过这些方法。 Who have tried the same? 谁尝试过相同的方法?

I'm experimenting with that right now and here are my observations: 我现在正在对此进行试验,这是我的观察结果:

On iPhone 4 , that is not working at all. 在iPhone 4上 ,这根本不起作用。 Even if you set pausesLocationUpdatesAutomatically to YES it keeps pausesLocationUpdatesAutomatically as NO(0). 即使将pausesLocationUpdatesAutomatically自动设置为YES,它也会使pausesLocationUpdatesAutomatically自动保持为NO(0)。 No warnings, what kind of API design anti-pattern is this! 没有警告,这是什么样的API设计反模式!

On iPhone 5 pausesLocationUpdatesAutomatically is YES (1) by default. 在iPhone 5上 ,默认情况下,pauseLocationUpdatesAutomatically自动为YES(1)。 And locationManagerDidPauseLocationUpdates is called. 并调用locationManagerDidPauseLocationUpdates。 I'm having a bad luck having the locationManagerDidResumeLocationUpdates called. 我不幸遇到了调用locationManagerDidResumeLocationUpdates的情况。 I'm also puzzled how this is going to be called if GPS is off? 我也很困惑,如果GPS关闭,怎么称呼它? Will it be called once user reaches the next network cell? 一旦用户到达下一个网络单元,它将被调用吗? Even that is not my experience, it is not ever called. 即使那不是我的经验,也永远不会这样。

So far, looks to me as one of the least consistent changes in iOS6. 到目前为止,在我看来,这是iOS6中变化最少的更改之一。 I might be going with just pausesLocationUpdatesAutomatically = NO for all scenarios and will hope that works ok on all models with iOS6. 我可能只是在所有情况下都使用pausesLocationUpdatesAutomatically = NO进行操作,希望在所有装有iOS6的型号上都能正常工作。

[Update - 4-Mar-2013]. [更新-2013年3月4日]。 I looked through the Apple's presentation for location changes in iOS6 and they suggest to use the region changes monitoring to "un-pause" once you get region changes event. 我在Apple的演示文稿中查看了iOS6中的位置更改,他们建议一旦获得区域更改事件,就可以使用区域更改监视功能来“取消暂停”。 Though this is not suitable for my scenarios as user might go/run/drive for a kilometer or two until such an event happens. 尽管这不适合我的情况,因为在发生此类事件之前,用户可能会行驶一公里或行驶一两公里。

我遇到了同样的问题,发现您必须将属性pausesLocationUpdatesAutomatically自动设置为YES

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM