解决方法
那你也可以在UIView上使用addGestureRecognizer方法,如下所示:
// In some View controller UITapGestureRecognizer *tapGR; tapGR = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)] autorelease]; tapGR.numberOfTapsrequired = 1; [myUIView addGestureRecognizer:tapGR]; // Add a delegate method to handle the tap and do something with it. -(void)handleTap:(UITapGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { // handling code } }