Симулятор проблем с GPS на iPhone не реагирует - PullRequest
0 голосов
/ 21 октября 2010

Я пытаюсь создать простое приложение GPS для отображения простых данных в симуляторе. У меня нет ошибок, просто не могу получить данные. Метод didFailWithError - единственное, что я могу заставить работать :), это код:

- (void)viewDidLoad 
{  
 [super viewDidLoad];

 lm = [[CLLocationManager alloc] init];
 if([CLLocationManager locationServicesEnabled])
 {
  lm.delegate = self;
  lm.desiredAccuracy = kCLLocationAccuracyBest;
  //lm.distanceFilter = 1000.0f;
  [lm startUpdatingLocation];
 }

}


- (void) locationManager: (CLLocationManager *) manager
didUpdateToLocation: (CLLocation *) newLocation
fromLocation: (CLLocation *) oldLocation{
 NSString *lat = [[ NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
 txtLatitude.text = lat;

 NSString *lng = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
 txtLongitude.text = lng;

 NSString *acc = [[NSString alloc] initWithFormat:@"%g", newLocation.horizontalAccuracy];
 txtAccuracy.text = acc;

 [acc release];
 [lat release];
 [lng release];
}
- (void) locationManager:(CLLocationManager *)manager 
didFailWithError: (NSError *) error
{
 NSString *msg = [[NSString alloc] initWithString:@"Error obtaining location"];
 UIAlertView *alert = [[ UIAlertView alloc] initWithTitle:@"Error" 
              message:msg 
             delegate:nil 
             cancelButtonTitle:@"Done" 
             otherButtonTitles:nil];
 [alert show];
 [msg release];
 [alert release];
}

1 Ответ

2 голосов
/ 21 октября 2010

Он никогда не перемещается в симуляторе.

http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/125-Using_iPhone_Simulator/iphone_simulator_application.html

"Функция определения местоположения ядра

Перемещение, о котором сообщает платформа CoreLocation в симуляторе, фиксируется наследующие координаты (точность 100 метров), которые соответствуют 1 бесконечному циклу, Купертино, Калифорния 95014.

Широта: 37.3317 Северная долгота: 122.0307 Западная *

Вы можете попробовать добавить простую случайную или временнуюсобытие, которое явно проверяет метод didUpdate ... с поддельными данными вашего предпочтения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...