Iphone iOS 6 CoreLocation不工作

Iphone iOS 6 CoreLocation不工作,iphone,ios,ios6,core-location,Iphone,Ios,Ios6,Core Location,我制作了一个定位应用程序。但核心位置不起作用。 我在我的iPhone上测试了其他iPhone应用程序 就像谷歌地球,一个导航软件。 其他应用程序也不起作用 为什么不更新位置 为什么“locationManager:didUpdateToLocation:fromLocation:”消息只调用了2次 也许。。。我的iPhone坏了?或者iOS 6 CoreLocation框架有一些bug 位置服务-iPhone上的设置 Info.plist armv7 加速计 定位服务 全球定位系统 传声器 磁

我制作了一个定位应用程序。但核心位置不起作用。 我在我的iPhone上测试了其他iPhone应用程序
就像谷歌地球,一个导航软件。 其他应用程序也不起作用
为什么不更新位置
为什么“locationManager:didUpdateToLocation:fromLocation:”消息只调用了2次

也许。。。我的iPhone坏了?或者iOS 6 CoreLocation框架有一些bug

位置服务-iPhone上的设置

Info.plist

  • armv7
  • 加速计
  • 定位服务
  • 全球定位系统
  • 传声器
  • 磁强计
代码示例:

- (CLLocationManager *)setupLocationManager
{
  if ([CLLocationManager locationServicesEnabled] && [CLLocationManager headingAvailable]) {

     CLLocationManager *locationManager = [[CLLocationManager alloc] init];
     locationManager.delegate = self;
     locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
     locationManager.distanceFilter = kCLDistanceFilterNone;
     locationManager.headingFilter = kCLHeadingFilterNone;
     [locationManager startUpdatingLocation];
     [locationManager startUpdatingHeading];
     return locationManager;
  }
  return nil;
}

- (CLLocationManager *)locationManager
{
  switch([CLLocationManager authorizationStatus])
  {
    case kCLAuthorizationStatusAuthorized:
      _deltaTimeLocationReceived = 0.0;
      if (_locationManager == nil)
        _locationManager = [self setupLocationManager];
       return _locationManager;

      case kCLAuthorizationStatusDenied:
      case kCLAuthorizationStatusRestricted:
        if (_locationManager)
          _locationManager = nil;
        return _locationManager;

      case kCLAuthorizationStatusNotDetermined:
        _deltaTimeLocationReceived = 0.0;
        if (_locationManager == nil)
          _locationManager = [self setupLocationManager];
        return nil;
    }
    return nil;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
  NSLog(@"%@ %@", NSStringFromSelector(_cmd), newLocation.description); 
  if (self.locationManager) _locationSignal++;
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
  NSLog(@"%@ %@", NSStringFromSelector(_cmd), error.description);
}

您有来自委托方法的任何消息吗

如果没有消息,请检查类的接口描述


@接口

在iOS 6中,苹果通过实现AutoPause API对核心位置进行了突破性的更改。当应用程序进入后台时,AutoPause API暂停位置更新,并应用于两个条件(即用户不移动、无位置修复、用户停止活动)。为了准确处理暂停事件,苹果请求帮助更好地预测是否暂停位置更新,设置活动类型(即导航、健身、其他)。 根据iOS 6编译应用程序时,默认情况下会启用AutoPause API

最简单的修复方法是通过始终将“pausesLocationUpdatesAutomatically”设置为“否”,暂时禁用AutoPause API。即使应用程序在后台运行,也会发送位置更新,就像它在 详情如下:

-(void)locationManager:(CLLocationManager*)manager已更新位置:(CLLocation*)新位置fromLocation:(CLLocation*)旧位置
委托不再存在于ios 6中

改用

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray*)locations
检查

此代码(以及pausesLocationUpdatesAutomatically)将仅在XCode 4.5(其中基本SDK为6)中编译

如果您希望以6.0之前的iOS版本为目标,请使用此宏

#define IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
无论您在何处创建CLLocationManager对象

if(IOS_VERSION_GREATER_THAN_OR_EQUAL_TO (@"6.0"))
{
    locationManagerObj.pausesLocationUpdatesAutomatically = NO;
}

当从Xcode 4.5编译时,locationManager代理应在所有版本中工作。是否清除了安全设置?是,我将位置服务设置为打开。谢谢。设置->常规->重置->重置位置和隐私。谢谢jessedc。我确实重置了位置和隐私。但是我的iPhone不能正常工作。问题不在iOS 6中。CLLocationManager适用于许多应用程序。我添加了代码“pausesLocationUpdatesAutomatically=NO”。我有这个需要。但是你见过调用自动暂停回调吗?*我指的是所有支持的版本