美文网首页
UITapGestureRecognizer 手势点击无效

UITapGestureRecognizer 手势点击无效

作者: jadn | 来源:发表于2016-09-06 11:10 被阅读2138次

    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 手势点击无效

          本文链接:https://www.haomeiwen.com/subject/omjdettx.html