我正嘗試將我的一個應用程序更新到IOS9和Xcode 7.2.1。位置管理器在早期版本中工作,但現在不起作用。沒有錯誤或警告......沒有。看來我的代碼沒有進入「didUpdateLocations」。我的代碼在下面;位置管理器沒有獲取位置
- (void)setupViewController {
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[self.locationManager requestAlwaysAuthorization];
}
locationManager.desiredAccuracy = 100;
//locationManager.requestLocation;
[locationManager startUpdatingLocation];
//return coordinate;
[self performSelector:@selector(stopUpdatingLocation:) withObject:@"Timed Out" afterDelay:5];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"Doesn't get here.");
self.bestEffortAtLocation = newLocation;
latitudeString = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
longitudeString = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
There is other code here that gets city, country, etc.
不知道在這一點上該怎麼做。我尋找類似的問題,但沒有發現任何東西。
非常感謝。完美工作。 – tombuarts