当前使用的是Xcode 6;
在iOS 8.1中使用Mapkit.h和coreLocation框架生成地图视图时,单击按钮而不是在标签中显示纬度和经度值时,它显示崩溃错误为:无法识别的选择器已发送到实例0x797a4e20
在GPSController.m中
- (IBAction)tap:(id)sender {
NSLog(@"button clicked");
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[locationManager startMonitoringSignificantLocationChanges];
}
应该在此获取值:
(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"location info object=%@", [locations lastObject]);
CLLocation* location = [locations lastObject];
NSLog(@"latitude %+.6f, longitude %+.6f\n",
location.coordinate.latitude,
location.coordinate.longitude);
self.lat.text = [NSString stringWithFormat:@"%+.6f", location.coordinate.latitude];
self.longi.text = [NSString stringWithFormat:@"%+.6f", location.coordinate.longitude];
[self performSegueWithIdentifier:@"Map" sender:self];
}
在您的代码中执行以下检查。
action:@selector(tap:)
而不是action:@selector(tap)
处理didFailWithError
位置管理器的委托以获取有关错误语法的更多详细信息:
(无效)locationManager:(CLLocationManager *)经理didFailWithError:(NSError *)错误
ID为“地图”的Segue支票确实存在
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句