开发者

iPhone GPS problem simulator doesn't react

I am trying to create simple GPS application just to display simple data in simulator. I have no errors just cant obtain data. "didFailWithError" method is the only I can get to work :), this is the code:

- (void)viewDidLoad 
{  
 [super viewDidLoad];

 lm = [[CLLocationManager alloc] init];
 if([CLLocationManager locationServ开发者_开发技巧icesEnabled])
 {
  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];
}


It doesnt move ever in the simulator.

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

"Core Location Functionality

The relocation reported by the CoreLocation framework in the simulator is fixed at the following coordinates (accuracy 100 meters), which correspond to 1 Infinite Loop, Cupertino, CA 95014.

Latitude: 37.3317 North Longitude: 122.0307 West"

You could try adding a simple random or timed event which pings the didUpdate... method explicitly with fake data of your preference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜