我正在使用MKMapKit和CLLocation更新我的实时应用。该应用程序自ios 6以来尚未更新。我已更新并提取了我的viewdidload如下:
table1
查询如下: 1.现在应用程序已经在ios 9和ios 8和9中得到遵守,是否有任何遗漏?
但是我得到了同样的错误:
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 ];
我做错了什么?
答案 0 :(得分:0)
确保您已将NSLocationWhenInUseUsageDescription
和NSLocationAlwaysUsageDescription
个关键字添加到您的app plist中。
从plist
开始,现在必须将这两项添加到ios8
。
另请注意,您需要使用UIAlertController
而不是UIAlertView
。UIAlertView
已被弃用。