如何删除错误 - [CLLocationManager requestAlwaysAuthorization]

时间:2015-12-30 18:03:56

标签: ios objective-c mapkit cllocation

我正在使用MKMapKit和CLLocation更新我的实时应用。该应用程序自ios 6以来尚未更新。我已更新并提取了我的viewdidload如下:

table1

查询如下: 1.现在应用程序已经在ios 9和ios 8和9中得到遵守,是否有任何遗漏?

  1. 我更改了mapView snipet并将其放在位置代码
  2. 之前

    但是我得到了同样的错误:

    if (nil == locationManager)
        locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [ locationManager requestAlwaysAuthorization];
    locationManager.allowsBackgroundLocationUpdates = YES;
    if (![CLLocationManager locationServicesEnabled] )   {
    
      UIAlertView *locationNotRunning= [[UIAlertView alloc] initWithTitle:@"Sorry!" message:@"Location Services are not enabled.  Application will terminate."
    delegate:nil
    cancelButtonTitle:@"OK"
    otherButtonTitles:nil];
    [locationNotRunning show];
    [self  performSelector:@selector(dismissNamedAlert:) withObject:locationNotRunning afterDelay:13];
      }
    if ([locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) { locationManager.pausesLocationUpdatesAutomatically = NO; }
    
    then in the same method, the following:
    
    
    CGRect availableArea = CGRectMake(0 , 0,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height - 110); /
    mapView = [[ MKMapView alloc ] initWithFrame:availableArea];
    
    
    [mapView setDelegate:self];
      [mapView removeAnnotations:mapView.annotations];
      [mapView setZoomEnabled:YES];
      [mapView setScrollEnabled:YES];
      [mapView setShowsUserLocation:YES];
      mapView.showsUserLocation=YES;
      [self.view addSubview:mapView ];
      [locationManager startUpdatingLocation ];
    

    我做错了什么?

1 个答案:

答案 0 :(得分:0)

确保您已将NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription个关键字添加到您的app plist中。

plist开始,现在必须将这两项添加到ios8

另请注意,您需要使用UIAlertController而不是UIAlertViewUIAlertView已被弃用。