Ios 已将无法识别的选择器发送到MapView iof OS中的实例
目前使用Xcode 6 在iOS 8.1中使用Mapkit.h和coreLocation framework生成地图视图时,单击按钮而不是在标签中显示纬度和经度值时,会将崩溃错误显示为:无法识别的选择器发送到实例0x797a4e20 在GPSController.m中Ios 已将无法识别的选择器发送到MapView iof OS中的实例,ios,objective-c,Ios,Objective C,目前使用Xcode 6 在iOS 8.1中使用Mapkit.h和coreLocation framework生成地图视图时,单击按钮而不是在标签中显示纬度和经度值时,会将崩溃错误显示为:无法识别的选择器发送到实例0x797a4e20 在GPSController.m中 - (IBAction)tap:(id)sender { NSLog(@"button clicked"); locationManager.delegate = self; locationManage
- (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];
}
您还应该给出
(void)locationError:(NSError *)error in{
//你的逻辑
}在代码中执行以下检查
操作:@selector(点击:)
而不是操作:@selector(点击)
显示完整的错误消息。它应该告诉您无法识别的确切类和选择器。您还应该准确地确定它在哪一行崩溃。转到断点选项卡(Cmd+7),按
+
,然后添加一个异常断点。现在,它应该在调用无法识别的选择器的行上崩溃。错误日志:[GPSViewController locationError:]:无法识别的选择器发送到实例0x7a979070(lldb)-(void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)Error{[self.delegate locationError:Error];//此时出错}什么是自我授权??它是否正在实现方法()locationError: