imageview传tag参数--直接传即可

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cos_sin_tan/article/details/50897885

  UIImageView *imageView = [[UIImageView alloc]init];

                    imageView.image = [UIImage imageNamed:@"Recordjiahao"];

                    [view2 addSubview:imageView];

            imageView.tag = 2;  ////////////////////////////////////这边这句话

                    imageView.userInteractionEnabled = YES;

                    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(picAddImageClicked:)];

                    

                    [imageView addGestureRecognizer:singleTap];

                    

                    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {

                        

                        make.center.equalTo(view2);

                        

                        make.size.mas_equalTo(CGSizeMake(30, 30));

                    }];



-(void)picAddImageClicked:(UITapGestureRecognizer *)recognizer{

    nslog(@"image tag is %ld",recognizer.view.tag);  ///////这边这句话

    if ([self.delegate respondsToSelector:@selector(picCellAddImageClicked:)]) {

        [self.delegate picCellAddImageClicked:recognizer];

    }

}


阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页