当我在任何地方按下地图视图时,地图由于未捕获的异常而终止。
-[MapViewController handleGuesture]:无法识别的选择器发送到实例 0xa046cc0 2013-04-15 10:41:23.316 CabServiceProvider [912:c07] *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[MapViewController handleGuesture]:无法识别的选择器发送到实例 0xa046cc0”
Here is code which is causing this error.
- (void)viewDidLoad{
[super viewDidLoad];
[self.mapView.userLocation addObserver:self
forKeyPath:@"location"
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
context:NULL];
mapView.userTrackingMode=YES;
[mapView setUserTrackingMode:MKUserTrackingModeFollow];
UITapGestureRecognizer *gr=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGuesture)];
gr.numberOfTapsRequired=1;
[mapView addGestureRecognizer:gr];
}
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer{
if (gestureRecognizer.state != UIGestureRecognizerStateEnded)
return;
CLLocationCoordinate2D coordinate; //= annotationView.annotation.coordinate;
NSLog(@"dropped at %f,%f", coordinate.latitude, coordinate.longitude);
CGPoint touchPoint = [gestureRecognizer locationInView:mapView];
coordinate = [mapView convertPoint:touchPoint toCoordinateFromView:mapView];
NSLog(@"latitude %f longitude %f",coordinate.latitude,coordinate.longitude);
}
请帮助为什么会出现此错误。