問題描述
我已經按照Session 303 - 從定位服務保持跟蹤"WWDC 2012 中的 AutoPause 示例
I've follow the example of AutoPause from "Session 303 - Staying on track from Location Services" WWDC 2012
在示例中,您可以看到 AutoPause 是如何啟用的,并且有兩個方法被調用:
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:
在 iPhone 4 上,這根本不起作用.即使您將 pausesLocationUpdatesAutomatically 設置為 YES,它也會將 pausesLocationUpdatesAutomatically 設置為 NO(0).沒有警告,這是什么 API 設計反模式!
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!
在 iPhone 5 上 pausesLocationUpdatesAutomatically 默認為 YES (1).并調用 locationManagerDidPauseLocationUpdates.我在調用 locationManagerDidResumeLocationUpdates 時運氣不好.我也很困惑,如果 GPS 關閉,這將如何調用?一旦用戶到達下一個網絡單元,它會被調用嗎?即使那不是我的經驗,也從來沒有被調用過.
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.
到目前為止,在我看來,這是 iOS6 中一致性最差的變化之一.對于所有場景,我可能只使用 pausesLocationUpdatesAutomatically = NO,并希望在 iOS6 的所有型號上都能正常工作.
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.
[更新 - 2013 年 3 月 4 日].我查看了 Apple 關于 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 自動暫停不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!