CLLocationmanager委托方法在xcode6中不起作用 [英] CLLocationmanager delegate method is not working in xcode6

查看:108
本文介绍了CLLocationmanager委托方法在xcode6中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i am created new project in Xcode6 and added the old files to this project(old files is created in xcode5) ,But whats happening is everything working fine, but "didUpdateToLocation" delegate method is not calling, i also used "didUpdateLocations" delegate method but both are not working.Code i have used from old file but the core location framework has been added from xcode6 ,I don't know what i am missing please anyone guide me to get a solution.

推荐答案

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

If you're testing this on iOS 8 device / Simulator, old location code may not work because of the way the iOS 8 handles Location Services permission access. As of current iOS 8 beta, you need to use new -requestWhenInUseAuthorization method:

- (void)updateCurrentLocation {

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

    [self.locationManager startUpdatingLocation];
}

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

The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method.

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

这篇关于CLLocationmanager委托方法在xcode6中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆