我在 mapView 上放了许多注释。这适用于下面的代码
float userLatitude = [[userDict objectForKey:@"lat"]floatValue];
float userLongitude = [[userDict objectForKey:@"long"]floatValue];
NSString *someString = [someArray objectAtIndex:i];
NSString *anotherString = [anotherArray objectAtIndex:i];
CLLocationCoordinate2D loopCoord = {.latitude = userLatitude, .longitude = userLongitude};
MapAnnotationViewController *addAnnotation = [[MapAnnotationViewController alloc] initWithCoordinate:loopCoord];
self.localImage = [UIImage imageNamed:@"first.png"];
[addAnnotation setTitle:someString];
[addAnnotation setSubTitle:anotherString];
[mainMapView addAnnotation:addAnnotation];
我本质上想添加一个自定义触摸,即使当一个人触摸地图上的每个注释时也会触发。该方法需要从地图上的特定位置触发(不是标准的 didSelect)我如何标记或将每个注释中的参数传递给委托方法:
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
我如何获得这样的代码:
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
[singleFingerTap release];
//The event handling method
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:[recognizer.view superview]];
//Do stuff here...
}
传递给didSelectAnnotationView
每个特定的注释?