我开发了一个应用程序,我试图在委托方法“applicationDidBecomeActive”中获取当前设备位置并且它工作正常,但是当我在 Xcode 8 beta 6 和 iOS beta 10.7 上测试我的相同代码时出现了问题。屏幕被连续的警报轰炸,说“允许“应用程序”在您使用应用程序时访问您的位置”。我无法单击“允许”/“不允许”。我的代码是:
-(void) startLocationService {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (![CLLocationManager locationServicesEnabled] || status == kCLAuthorizationStatusDenied || status == kCLAuthorizationStatusRestricted) {
DLog(@"Locations disabled or status not permiting use of locations systems.");
self.currentLocation = nil;
[self sendNotificationforErrorMessage:ERROR_MSG_LOCATION_SERVICE];
}
else {
[self createLocationManager];
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
if (status == kCLAuthorizationStatusNotDetermined) {
[locationManager requestWhenInUseAuthorization];
}
}
else {
[self startLocationManager];
}
}
}
-(void)createLocationManager {
self.currentLocation = nil;
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
locationManager.delegate = self;
}
-(void)startLocationManager {
[locationManager startUpdatingLocation];
[self performSelector:@selector(locationServiceTimedout)
withObject:nil
afterDelay:timeOutValue];
}
我测试过的场景: 1) 在 Xcode8 beta6 中编译应用程序并在 iOS 9 设备上成功运行 2) 在 Xcode8 beta6 中编译应用程序并在 iOS10 设备上被警报轰炸。
我试过用谷歌搜索它,但没有运气。任何指针都受到高度赞赏。