Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.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
Ios 已将无法识别的选择器发送到MapView iof OS中的实例_Ios_Objective C - Fatal编程技术网

Ios 已将无法识别的选择器发送到MapView iof OS中的实例

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

目前使用Xcode 6

在iOS 8.1中使用Mapkit.h和coreLocation framework生成地图视图时,单击按钮而不是在标签中显示纬度和经度值时,会将崩溃错误显示为:无法识别的选择器发送到实例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];

}

您还应该给出

(void)locationError:(NSError *)error in{
//你的逻辑
}在代码中执行以下检查

  • 检查“点击”iAction是否与某些cocoa控件元素绑定(如UIbutton touchUpInside事件)
  • 检查类中是否声明了“点击”iAction
  • 您可能正在使用
    操作:@selector(点击:)
    而不是
    操作:@selector(点击)
  • 处理Location Manager的委托以获取有关错误的更多详细信息 语法:

    (无效)locationManager:(CLLocationManager*)经理
 didFailWithError:(n错误*)错误

  • 检查ID为“Map”的序列是否存在


  • 显示完整的错误消息。它应该告诉您无法识别的确切类和选择器。您还应该准确地确定它在哪一行崩溃。转到断点选项卡(Cmd+7),按
    +
    ,然后添加一个
    异常断点。现在,它应该在调用无法识别的选择器的行上崩溃。错误日志:[GPSViewController locationError:]:无法识别的选择器发送到实例0x7a979070(lldb)-(void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)Error{[self.delegate locationError:Error];//此时出错}什么是自我授权??它是否正在实现方法()locationError: