我想在用户点按图片时全屏显示图片。 有人可以帮我吗? 我的ImageView在TableViewCell中。 这是我尝试过的:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
ImageListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.propertyImageView.frame = [UIScreen mainScreen].bounds;
cell.propertyImageView.image = [imageList objectAtIndex:indexPath.row];
}
答案 0 :(得分:1)
这很容易:
-(void)removeImage {
UIImageView *imgView = (UIImageView*)[self.view viewWithTag:100];
[imgView removeFromSuperview];
}
-(void)addImageViewWithImage:(UIImage*)image {
UIImageView *imgView = [[UIImageView alloc] initWithFrame:self.view.frame];
imgView.contentMode = UIViewContentModeScaleAspectFit;
imgView.backgroundColor = [UIColor blackColor];
imgView.image = image;
imgView.tag = 100;
UITapGestureRecognizer *dismissTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeImage)];
dismissTap.numberOfTapsRequired = 1;
[imgView addGestureRecognizer:dismissTap];
[self.view addSubview:imgView];
}
从你的表委托中调用:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self addImageViewWithImage:[imageList objectAtIndex:indexPath.row]];
}