0

我尝试实现对自定义注释的点击,当它被点击时,表格上的行将被突出显示,

我尝试将手势识别器添加到自定义注释中,但它不起作用。

我也试过注释做选择方法,结果是一样的。

我的代码如下;

   UITapGestureRecognizer *singlePress =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSinglePress:withIndex:temp:)];

    [annotationView addGestureRecognizer:singlePress];

    [annotationView setUserInteractionEnabled:YES];
4

1 回答 1

1

在 annotationView 上添加标注按钮,例如,

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
myCustomAnnotationView.rightCalloutAccessoryView = rightButton;

并调用方法

-(void)showDetails:(UIButton *) calOutBtn
{
   // do your stuff;
}

编辑:

在你的情况下,你需要添加这样的,

UITapGestureRecognizer *gestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TouchViewMethod:)];
gestureRec.numberOfTouchesRequired = 1;
gestureRec.numberOfTapsRequired = 1;
[ annotationView addGestureRecognizer:gestureRec];
于 2013-09-06T07:17:37.527 回答