2012-02-16 31 views
0

I'l想知道GPS位置/地區監測概括+如何開啓/關閉對GPS信號(圖標)在背景[iOS的]

A)如果可能的話完全關閉GPS的使用當應用程序處於後臺模式並終止它時(長按「主頁按鈕」,點擊相應任務的「X」),即使「區域監控」處於活動狀態且App中有相應的活動標誌.plst。

另外我想回顧一下如何監視設備位置;我認爲有三種方式: - [locationManager startUpdatingLocation] - [locationManager startMonitoringSignificantLocationChanges]; - [locationManager startMonitoringForRegion:region desiredAccuracy:accuracy]; B)我不明白他們「可以」/「不可以」/「必須」在同一時間運行。例如:startUpdatingLocation和startMonitoringSignificantLocationChanges是互斥的,沒關係,但startMonitoringForRegion怎麼樣?

C)我可以只使用startMonitoringForRegion而不使用startMonitoringSignificantLocationChanges嗎? D)如果我在同一時間同時使用兩種通知,我可以在進入/退出監控區域時收到兩個通知嗎?我怎樣才能避免它? 我這種情況下,我認爲應該實現這樣的事情:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
BOOL crossedBoundary = [self checkIfNewLocationHasCrossedMyMonitoredRegionBoundary:newLocation ]; 
if (crossedBoundary) NSLog(@"Crossed the boundary"); 
} 

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"Crossed the boundary"); } 

E)我如何關閉/開啓startMonitoringForRegion而應用程序是在後臺?

非常感謝。 我是從 「區域」 和 「麪包屑」 蘋果例如 https://developer.apple.com/library/ios/#samplecode/Breadcrumb/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010048-Intro-DontLinkElementID_2

https://developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.html

回答

0

它將停止調用GPS

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation*) newLocation 
      fromLocation:(CLLocation *)oldLocation 
{ 
[manager stopUpdatingLocation]; 

} 
+0

部分...我認爲這隻會停止正常的本地化。 – 2012-02-16 12:09:50

1

回答您的問題,以便開始

答案A)據我所知,您無法關閉位置服務。

Ans B)startMonitoringForRegion正在監控區域進入/退出狀態的應用程序外運行服務。它的位置不會從正在從位置服務更新當前位置的CLLocationManager更新。它只是存儲與應用程序相關的受監視區域。

答案C)是的,你可以因爲startMonitoringForRegion增加了區域監控上的位置服務,其中爲startMonitoringSignificantLocationChanges是由在位置變化較大的處理,並更新到CLLocationManager監測技術分開使用使用locationManager:didUpdateLocations:。但在以前的答案startMonitoringForRegion提到將增加區域監測到該區域的監控位置服務

答案d)是的,你會收到單獨的更新位置。但請記住startMonitoringSignificantLocationChanges將位置更新爲CLLocationManger。因爲startMonitoringForRegion僅在邊界交叉點更新並且不更新位置。

答案E)你必須stopMonitoringRegion在應用程序的AppDelegate中添加到appEnterBackground