https://developer.apple.com/library/ios/samplecode/LocateMe/Listings/README_md.html
但我的代码根本不起作用. DIDupdatetoLocation永远不会被调用.
这是我的代码(在vIEwDIDLoad中)
_locationManager = [[CLLocationManager alloc] init];self.locationManager.delegate = self;// This is the most important property to set for the manager. It ultimately determines how the manager will// attempt to acquire location and thus,the amount of power that will be consumed.self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;// Once configured,the location manager must be "started"//// for iOS 8,specific user level permission is required,// "when-in-use" authorization grants access to the user's location//// important: be sure to include NSLocationWhenInUseUsageDescription along with its// explanation string in your Info.pList or startUpdatingLocation will not work.//if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization];}[self.locationManager startUpdatingLocation];[self performSelector:@selector(stopUpdatingLocationWithMessage:) withObject:@"Timed Out" afterDelay:30];
我已检查以确保启用locationServicesEnabled.
我已将NSLoationWhenInUseUsageDescription属性添加到info.pList文件中.我需要添加或启用任何服务吗?
我不能因为上帝的爱而弄清楚我做错了什么.有人可以帮我这个.
解决方法 在iOS8上收到dIDChangeAuthorizationStatus回调后,你必须调用startUpdatingLocation.//iOS 8 API changeif([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){ [self.locationManager requestWhenInUseAuthorization];}else{ [self.locationManager startUpdatingLocation];}
实现这个委托方法:
-(voID)locationManager:(CLLocationManager *)manager dIDChangeAuthorizationStatus:(CLAuthorizationStatus)status{ switch (status) { case kCLAuthorizationStatusNotDetermined: case kCLAuthorizationStatusRestricted: case kCLAuthorizationStatusDenIEd: { // do some error handling } break; default:{ [self.locationManager startUpdatingLocation]; } break; }}总结
以上是内存溢出为你收集整理的ios – 没有调用CLLocation didupdatetolocation全部内容,希望文章能够帮你解决ios – 没有调用CLLocation didupdatetolocation所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)