如果您有对图像(UIImageView 组件)的引用,您可能应该向所有图像添加一个 UITapGestureRecognizer 以检测点击。
例如在 viewDidLoad 中:
UITapGestureRecognizer *img1TapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(displayViewController1:);
[imageView1 addGestureRecognizer:img1TapGestureRecognizer];
UITapGestureRecognizer *img2TapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(displayViewController2:);
[imageView2 addGestureRecognizer:img2TapGestureRecognizer];
UITapGestureRecognizer *img3TapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(displayViewController3:);
[imageView3 addGestureRecognizer:img3TapGestureRecognizer];
然后通过以下方法显示您的视图控制器:
- (void)displayViewController1:(UITapGestureRecognizer *)recog {}
- (void)displayViewController2:(UITapGestureRecognizer *)recog {}
- (void)displayViewController3:(UITapGestureRecognizer *)recog {}