ios添加UIimageView添加事件

2017-09-12  本文已影响0人  frola_
UIImageView *ViewLabel = [[UIImageView alloc]init];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageTap:)];
 [_ViewLabel addGestureRecognizer:tap];
[_ViewLabel setUserInteractionEnabled:YES];

-(void)imageTap:(UIGestureRecognizer *)tap{
  XLPhotoBrowser *browser = [XLPhotoBrowser showPhotoBrowserWithImages:@[_commentmodel.images.filePath] currentImageIndex:0];
    browser.delegate = self;
    browser.datasource = self;    
}

注意一定要设置image view的setUserInteractionEnabled=YES

[_ViewLabel setUserInteractionEnabled:YES];
上一篇 下一篇

猜你喜欢

热点阅读