在我的应用程序中,我实现了 Cllocation 管理器以使用当前用户位置并且它工作正常。但是当应用程序进入后台或终止时,GPS位置图标会自动隐藏在ipod中。当我尝试使用 Iphone 时,图标不会隐藏。
所以,我找不到任何解决方案。帮我!!
我的代码如下:
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];
}
地图.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 中尝试相同的操作时,它会显示位置图标。