2012-10-27 53 views
0

在我的应用程序中,我实现了Cllocation管理器以使用当前用户位置&,它工作正常。但是当应用程序在后台输入或终止时,GPS位置图标会自动隐藏在iPod中。当我尝试与iPhone相同时,图标不会隐藏。Gps位置图标未关闭

所以,我找不到任何解决方案。帮我!!

我的代码如下:

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    { 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 

if(locationManager == nil) 

     locationManager =[[CLLocationManager alloc] init]; 

    self.locationManager.delegate = self; 

    self.locationManager.desiredAccuracy= kCLLocationAccuracyBest; 

    self.locationManager.distanceFilter= 5; 

    [locationManager startUpdatingLocation]; 
    [locationManager startUpdatingHeading]; 
} 


-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ 

    self.userLocation=newLocation; 

    [self.locationManager startMonitoringSignificantLocationChanges]; 
} 

Map.m

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
    [APPDELEGATE.locationManager startUpdatingLocation]; 

} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    self.map.delegate = self; 

    [self.map setShowsUserLocation:YES]; 
} 

如果我手动对我的iPod应用程序的位置服务,当应用程序是关闭,它没有显示位置图标。但是,当我尝试在iPhone中相同,它显示位置图标。

回答

0

我想你真正想要的是:

[self.locationManager stopUpdatingLocation]; 

直接以后,如果你想法力GER醒来在显著的位置变化,然后调用:

[self.locationManager startMonitoringSignificantLocationChanges]; 

相反适用回到不断更新:

[self.locationManager stopMonitoringSignificantLocationchanges]; 
[self.locationManager startUpdatingLocation]; 

注:在显着位置更改模式,在状态的图标当连续更新位置时,条仍然会显示相同。这不是一个需要关注的问题,因为在保守模式下,它在不需要时仍然关闭位置服务。
该ipod不支持startMonitoringSignificantLocationChanges。这就是为什么该指标在两台设备上表现不同。

您应该考虑到,正如您已经实施的那样,您正在使用任何第一个事件报告来查找经理的位置。这通常可能是陈旧的,缓存的,旧的或很可能非常不准确的。这是标准做法,使用一点测试,并为您的目的提供一个更合适的位置信息所需的机会。

请在Github上查看my handler以获得更多帮助,因为您可以使用位置服务。

1

终于我解决了这个问题,如下所示。

而不是

[self.locationManager startMonitoringSignificantLocationChanges]; 

在的appdelegate

我写,

[self.locationManager stopMonitoringSignificantLocationChanges];