CLLocationmanager委托方法在xcode6中不起作用

ash*_*elu 6 objective-c core-location ios ios7 xcode6

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

Rin*_*nov 11

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

- (void)updateCurrentLocation {

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

    [self.locationManager startUpdatingLocation];
}
Run Code Online (Sandbox Code Playgroud)

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

<key>NSLocationWhenInUseUsageDescription</key>
<string>We use your location to find places near you.</string>
Run Code Online (Sandbox Code Playgroud)