iphone - CLLocationManager - iPhone 应用程序中的自定义位置管理器

标签 iphone ios location cllocationmanager

我对这项技术很陌生,所以请帮助我。

我正在使用 CLLocationManager 获取当前位置,我的应用程序有自定义设置显示他是否允许当前位置的状态,即我们编写时默认出现的消息提示

[self.locationManager startUpdatingLocation];

如果用户点击不允许该消息提示并返回到我的应用程序自定义设置并更改关闭按钮以打开位置,我可以获取用户的当前位置。

这个东西怎么实现?

最佳答案

一旦用户拒绝了您的应用程序的位置服务,它只能在常规设置中重新打开 - 所以告诉用户然后将它们发送到那里。 (您可能想先使用 UIAlertView 通知他们。)

// If Location Services are disabled, restricted or denied.
if ((![CLLocationManager locationServicesEnabled])
    || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted)
    || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied))
{
    // Send the user to the location settings preferences
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"prefs:root=LOCATION_SERVICES"]];
}

关于iphone - CLLocationManager - iPhone 应用程序中的自定义位置管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10585897/

相关文章:

iphone - webview 中阅读页面的自定义 Split View

ios - 推送通知 : both didFailToRegister and didRegister delegate not calling

ios - 正在保存的图像未出现

ios - 选项卡式应用程序和导航栏(带有标题和图标)

node.js - 沃森视觉识别: How to find location of classified content

iphone - 如何用CGPath绘制多边形?

ios - 引用项目在 viewDidLoad 中安全地初始化

ios - Swift:使用协议(protocol)扩展专门化方法实现

Swift Firebase TableView 与当前用户的距离

java - 如何在没有双重请求的情况下使用 Google Places API 获取特定类型的 Lat Longs 列表?