6自动暂停不起作用

6自动暂停不起作用

本文介绍了iOS 6自动暂停不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从会话303 - 从定位服务保持正常运行WWDC 2012



中的自动暂停示例。你可以看到如何启用自动暂停,并且有两种方法被调用:

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

我也这样做了但是这些方法并不是永远不会被调用的。
谁试过了?

解决方案

我现在正在试验这个,下面是我的观察结果: / p>

在iPhone 4上,根本不起作用。即使您将pausesLocationUpdatesAutomatically设置为YES,它也会将pausesLocationUpdatesAutomatically保持为NO(0)。没有警告,这是什么样的API设计反模式是这样的!



在iPhone 5上默认情况下暂停位置更新自动为YES(1)。并调用locationManagerDidPauseLocationUpdates。我在调用locationManagerDidResumeLocationUpdates时运气不好。我也很疑惑,如果GPS关闭,这将如何被调用?一旦用户到达下一个网络单元,它会被调用吗?即使这不是我的经验,它也不会被调用。



到目前为止,我认为这是iOS6中最不一致的变化之一。我可能会在所有情况下仅使用pausesLocationUpdatesAutomatically = NO,并希望在使用iOS6的所有型号上都能正常工作。



[更新 - 2013年3月4日]。我浏览了苹果的演示文稿,了解iOS6中的位置更改,并且他们建议在发生区域更改事件后使用区域更改监视功能来暂停。虽然这不适合我的场景,因为用户可能会去/运行/开车一两公里或两个直到发生这样的事件。


I've follow the example of AutoPause from "Session 303 - Staying on track from Location Services" WWDC 2012

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. Even if you set pausesLocationUpdatesAutomatically to YES it keeps pausesLocationUpdatesAutomatically as NO(0). No warnings, what kind of API design anti-pattern is this!

On iPhone 5 pausesLocationUpdatesAutomatically is YES (1) by default. And locationManagerDidPauseLocationUpdates is called. I'm having a bad luck having the locationManagerDidResumeLocationUpdates called. I'm also puzzled how this is going to be called if GPS is off? 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. I might be going with just pausesLocationUpdatesAutomatically = NO for all scenarios and will hope that works ok on all models with iOS6.

[Update - 4-Mar-2013]. 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. Though this is not suitable for my scenarios as user might go/run/drive for a kilometer or two until such an event happens.

这篇关于iOS 6自动暂停不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:32