我正在尝试在 UIImageView 上实现轻击手势识别器。但是我无法让处理点击事件的方法触发。我已经将我的代码与 stackoverflow 上许多类似问题的答案进行了比较,但问题仍然存在。以下是我的应用程序中的相关代码。有人可以告诉我我做错了什么吗?
视图控制器.h
IBOutlet UIImageView *topLeftImage;
-(IBAction)handleSingleTap:(UITapGestureRecognizer*)gestureView;
视图控制器.m
- (void)viewDidUnload
{
[super viewDidUnload];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
topLeftImage.userInteractionEnabled = YES;
[topLeftImage addGestureRecognizer:singleTap];
}
- (void)handleSingleTap:(UITapGestureRecognizer *)gestureRecognizer {
NSLog(@"Tap detected. Booyah!");
}