iOS - 給imageView添加點擊

採用 UITapGestureRecognizerweb

UIImageView *photoImage = [[UIImageView alloc] init];
photoImage.userInteractionEnabled = YES;

UITapGestureRecognizer *photoImageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoImageClicked)];

photoImageTap.numberOfTapsRequired = 1;
photoImageTap.numberOfTouchesRequired = 1;
[photoImage addGestureRecognizer:photoImageTap];
-(void) photoImageClicked{
 //點擊響應
}