【问题标题】:How to use the CLLocationManager to update location without asking user to enable the service?如何在不要求用户启用服务的情况下使用 CLLocationManager 更新位置?
【发布时间】:2011-05-03 03:18:30
【问题描述】:

有什么方法可以测试用户位置服务是否启用 询问用户?

如果服务是,我想要做的是使用用户位置信息 已经开启,或者如果服务关闭则不使用它。我不想问用户 启用服务。

有什么方法可以做到这一点吗?

谢谢。

【问题讨论】:

    标签: location mkmapview cllocationmanager prompt


    【解决方案1】:

    是的,使用locationServicesEnabled

    if ([CLLocationManager locationServicesEnabled]) {
        // do you stuff
    }
    

    【讨论】:

    • 这似乎不适合我。这是我所做的:if ([CLLocationManager locationServicesEnabled]) { CLLocationManager *clManager = [[CLLocationManager alloc] init]; [clManager setDesiredAccuracy:kCLLocationAccuracyBest]; [clManager startUpdatingLocation]; } 它仍然问我是否允许使用用户位置。
    • @Steven - 它总是会询问用户是否允许应用使用他们的位置。可以为设备启用位置,但为您的设备禁用位置。用户需要明确允许您的应用使用该位置。
    • @Steven - 读到这让我听起来很迟钝 - “可以为设备启用位置,但为你的设备禁用位置。”。我的意思是,可以为设备启用位置,但为您的应用禁用位置 :)
    猜你喜欢
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 2015-05-31
    • 1970-01-01
    • 2011-01-29
    相关资源
    最近更新 更多