【问题标题】:CLLocationmanager delegate method is not working in xcode6 [duplicate]CLLocationmanager委托方法在xcode6中不起作用[重复]
【发布时间】:2014-09-18 06:25:11
【问题描述】:

我在 Xcode6 中创建了新项目并将旧文件添加到该项目中(旧文件在 xcode5 中创建),但是发生的事情是一切正常,但是 “didUpdateToLocation”委托方法没有调用,我也使用了“didUpdateLocations”委托方法,但两者都不起作用。我使用旧文件中的代码,但核心位置框架已从 xcode6 添加,我不知道我错过了什么请任何人指导我获得解决方案。

【问题讨论】:

    标签: ios objective-c ios7 core-location xcode6


    【解决方案1】:

    如果您在 iOS 8 设备/模拟器上进行测试,由于 iOS 8 处理位置服务权限访问的方式,旧的位置代码可能无法正常工作。从目前的 iOS 8 测试版开始,您需要使用新的-requestWhenInUseAuthorization 方法:

    - (void)updateCurrentLocation {
    
        if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
            [self.locationManager requestWhenInUseAuthorization];
        }
    
        [self.locationManager startUpdatingLocation];
    }
    

    用户提示包含来自应用程序 Info.plist 文件中 NSLocationWhenInUseUsageDescription 键的文本,调用此方法时需要该键的存在。

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>We use your location to find places near you.</string>
    

    【讨论】:

    • +1 我没有在文档中看到此更新。
    猜你喜欢
    • 1970-01-01
    • 2011-03-12
    • 2011-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多