一个tableViewCell 里添加了三个imageView ,分别通过代理加上了点击事件,其中之一代码如下:
cell.h
@protocol imageDelegate
– (void) imageDelegate;
@property (nonatomic ,unsafe_unretained) id delegate;
cell.m
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTap:)];
self.left_image.userInteractionEnabled = YES;
tapGesture.numberOfTapsRequired = 1;
[self.left_image addGestureRecognizer:tapGesture];
– (void) imageTap:(UITapGestureRecognizer *) tapGesture{
if ([self.delegate respondsToSelector:@selector(imageDelegate)]) {
[self.delegate imageDelegate];
}
}
controller.m
– (void) imageDelegate{
ActivityDetailViewController *ac = [[ActivityDetailViewController alloc] initWithNibName:@”ActivityDetailViewController” bundle:nil];
[self presentViewController:ac animated:YES completion:^{
}];
以上是为一个imageView添加的跳转事件已经成功,但是剩下两给imageView以同样的方式添加点击事件之后,只有最后添加的那个点击事件可以响应,也就是说以以上这种方式添加了3个imageView添加了点击事件,只有第三个可以跳转成功!