我试着在一个自定义的注解上实现点击,当它被点击时,这个在表格上的行会被高亮显示。
我尝试将手势识别器添加到自定义注释,但它不起作用。
我也尝试了注解做了select方法,结果是一样的。
我的代码如下;
UITapGestureRecognizer *singlePress =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSinglePress:withIndex:temp:)];
[annotationView addGestureRecognizer:singlePress];
[annotationView setUserInteractionEnabled:YES];发布于 2013-09-06 15:17:38
在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];https://stackoverflow.com/questions/18652012
复制相似问题