我刚刚更新到Xcode 6 / iOS 8 SDK,我在模拟器中的位置服务模拟开始无法正常工作。我更新之前没事(我目前无法在真实设备上测试)。现在,当我选择一个模拟位置时,没有任何反应。委托的 - (void)locationManager :( CLLocationManager *)管理器didUpdateLocations :( NSArray *)位置方法未被调用。我重新启动了Xcode,清理了构建文件夹,没有任何改变。为什么会发生这种情况?
I've just updated to Xcode 6/iOS 8 SDK and my location service simulation in simulator started not working. It was fine before I updated (I'm currently unable to test on real device). Now, when I select a location for simulation, nothing happens. Delegate's -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations method is not called. I've restarted Xcode, cleaned the build folder, nothing changed. Why can this happen?
推荐答案从IOS 8起,您需要在启动CLLocationManager之前请求授权。
Since IOS 8 you need to ask for authorization before starting the CLLocationManager.
您是否正在调用其中一种方法?
Are you calling one of these methods?
[self.locationManager requestWhenInUseAuthorization]; // For foreground access [self.locationManager requestAlwaysAuthorization]; // For background access如果您在XCode 6之前创建了项目,则可能还需要添加新权限的info.plist条目。
If you have created the project before XCode 6, you probably also need to add the info.plist entry for the new permission.
有关详细信息,请查看此帖:位置服务在iOS 8中无效
For more details have a look at this post: Location Services not working in iOS 8
更多推荐
Xcode 6 / iOS 8位置模拟不起作用
发布评论