我沒有得到GPS位置更新。我正在使用iPad2來運行代碼。這是我的代碼:我沒有得到GPS位置更新。我錯過了什麼?
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//location
locationManager = [[[CLLocationManager alloc] init] autorelease]; // Create new instance of locMgr
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
NSLog(@"locationManager startUpdatingLocation"); //this core runs correctly
...
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSLog(@"Error: %@", [error description]);
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
location = [newLocation description];
NSLog(@"new location: %@", location); //never printed
}
我應該允許在首選項中的位置嗎?我期待iPad要求分享位置的權限,但我沒有得到任何。
謝謝
如果一點兒也不問權限自動,那麼你應該已經嘗試允許在首位置......如果甚至一點兒也不工作,那麼這件事情隱藏,因爲你的代碼看起來不錯 – tipycalFlow
@tipycalFlow我跑來自xCode的應用程序,所以我沒有在首選項中的應用程序。我的意思是,在這個應用程序的首選項中無法啓用/禁用位置權限。 (全球一個啓用)。 – aneuryzm
我應該在我的應用程序委託中添加代碼行以註冊位置通知嗎?我不明白這一點.. – aneuryzm