我尝试实现点击自定义注释,当点击它时,表格中的行将突出显示,
我尝试将手势识别器添加到自定义注释中,但它不起作用。
我alsa尝试过注释做了select方法,结果是一样的。
我的代码如下;
UITapGestureRecognizer *singlePress =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSinglePress:withIndex:temp:)];
[annotationView addGestureRecognizer:singlePress];
[annotationView setUserInteractionEnabled:YES];
答案 0 :(得分:1)
在annotationView上添加callout按钮,例如
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];