Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone GPS问题模拟器没有';不反应_Iphone_Objective C_Gps - Fatal编程技术网

iPhone GPS问题模拟器没有';不反应

iPhone GPS问题模拟器没有';不反应,iphone,objective-c,gps,Iphone,Objective C,Gps,我试图创建简单的GPS应用程序,只是为了在模拟器中显示简单的数据。我没有错误,只是无法获取数据。“didFailWithError”方法是我唯一可以使用的方法:),代码如下: - (void)viewDidLoad { [super viewDidLoad]; lm = [[CLLocationManager alloc] init]; if([CLLocationManager locationServicesEnabled]) { lm.delegate = self;

我试图创建简单的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];
}

它在模拟器中永远不会移动

“核心位置功能

模拟器中的CoreLocation框架报告的重新定位固定在以下坐标(精度100米),对应于加利福尼亚州库珀蒂诺的1个无限回路95014

纬度:北纬37.3317 经度:122.0307西“


您可以尝试添加一个简单的随机或定时事件来ping diddupdate。。。方法显式使用您偏好的伪数据。

我无法获取纬度和经度值。我知道应该有一些默认值,因为这是模拟器。但是我也买不到。我的问题是为什么从未调用“didUpdateToLocation”方法?我是不是遗漏了什么?我写了这个代码。使用didUploadToLocation方法中的断点运行此代码。但代码永远不会到达那里。总是以失败的方式完成。为什么会发生这种情况?没有理由不调用didUpload方法。