//查看是否加载了方法-分配了LocationManager并将CLLocationManagerDelegate包含在.h文件中
//View did Load Method- LocationManager is allocated and have included the CLLocationManagerDelegate in .h File -ViewDidLoad{ self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy=kCLLocationAccuracyBest; self.locationManager.distanceFilter=kCLDistanceFilterNone; [self.locationManager requestWhenInUseAuthorization]; [self.locationManager startMonitoringSignificantLocationChanges]; [self.locationManager startUpdatingLocation]; } // Location Manager Delegate Methods - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { NSLog(@"%@", [locations lastObject]); }
推荐答案
在plist中,您必须添加2个条目
In plist you have to add 2 entries
将两者都设为需要位置才能找到您所在的位置或任何东西
Make the string of both as "Location is required to find out where you are" or anything
self.locationManager = [[CLLocationManager alloc]init]; if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; CLAuthorizationStatus authorizationStatus= [CLLocationManager authorizationStatus]; if (authorizationStatus == kCLAuthorizationStatusAuthorized || authorizationStatus == kCLAuthorizationStatusAuthorizedAlways || authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse) { NSLog(@"You are authorized"); } self.locationManager.delegate = self; [self.locationManager startUpdatingLocation];希望这会有所帮助
更多推荐
永远不会调用iOS 8 CLLocationManagerDelegate方法
发布评论