UITapGestureRecognizer 手势点击无效

UILabel *productLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 20, 70, 17)];

productLabel.text = @"产品介绍";

productLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];

productLabel.textColor = [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1];

productLabel.userInteractionEnabled = YES; //必须开启这一句手势才有效果

UITapGestureRecognizer *productClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeProduct:)];

productClick.numberOfTapsRequired = 1;

productClick.cancelsTouchesInView = NO;

[productLabel addGestureRecognizer:productClick];

- (void)changeProduct:(UITapGestureRecognizer *)sender {

_isProductReviews = 1;

NSLog(@"%x",_isProductReviews);

[_myTableView reloadData];

}

你可能感兴趣的:(UITapGestureRecognizer 手势点击无效)