Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 每次启动应用程序时都会显示位置图标_Ios_Cllocationmanager - Fatal编程技术网

Ios 每次启动应用程序时都会显示位置图标

Ios 每次启动应用程序时都会显示位置图标,ios,cllocationmanager,Ios,Cllocationmanager,我的应用程序有问题-每次启动应用程序时,状态栏中的位置图标都会出现,即使我不使用位置 我的代码: AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[LocationManager manager] startLocation]; return YES;

我的应用程序有问题-每次启动应用程序时,状态栏中的位置图标都会出现,即使我不使用位置

我的代码:

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         [[LocationManager manager] startLocation];
         return YES;
    }
地点经理

@implementation LocationManager

- (id)init {
    self = [super init];
    if (self) {
        self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        self.locationManager.delegate = self;
    }
    return self;
}

+ (instancetype)manager {
    static LocationManager *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[LocationManager alloc] init];
    });
    return instance;
}

- (void)startLocation {
    [self.locationManager requestWhenInUseAuthorization];
    [self.locationManager startUpdatingLocation];
}

#pragma mark - CLLocatiomManager Delegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
...
}
在我允许定位服务使用我的位置后,每次启动我的应用程序时都会显示位置指示器(即使我从didFinishLaunchingWithOptions方法中删除了这一行)。 但若我在第一次发布(安装应用程序)时删除这一行,位置指示器不会出现,所以这只是我使用位置服务的一行


我希望当行被注释时,位置指示器不会出现。

基于您的Singleton类

Locationmanager将在调用时启动location

[[LocationManager manager] startLocation];
所以,只有位置图标显示在状态栏上。 当你需要一个位置的时候,你最好能打个电话给一个地点

获取位置后必须调用

[self.locationManager stopUpdatingLocation];

我意识到这是因为一个信号。 决定是:

[OneSignal setLocationShared:NO];

@franiis我的意思是,如果我评论这一行,指示器仍然出现,并且您在
info.plist
?@franiis Privacy-Location Always and When in Use用法说明中请求什么功能,Privacy-Location Always用法说明,Privacy-Location用法说明,Privacy-Location用法说明,Privacy-Location When in Use用法说明。我都写了,这有问题吗?我会试着去掉多余的ones@franiis我只留下了“使用时的隐私位置使用说明”,但问题仍然存在,但即使我评论这一行[[LocationManager]startLocation];第一次启动后,指示灯仍会出现并在5秒钟后消失。您的位置服务已被调用。因此,当你的应用程序进入后台或终止状态时,你必须停止更新位置。操作系统将在几秒钟后消失位置图标,但您在问题中从未提到过一个信号,因此提出的问题无法回答。