Q:

How to hide previous CellImage when a new cell is clicked in iOS app

I am showing a image in CellImage when any cell is clicked it works fine but problem is that when a new cell is selected then previous cell image is also visible i want that when user selects on new cell previous cellImage should be hidden. 
here is the code
-(IBAction)imageButtonAction:(id)sender{

CustomCell *cell = (CustomCell *) [[sender superview] superview];
UIButton *btn = (UIButton *)sender;
UIView *backimage = [[UIView alloc] initWithFrame:CGRectMake(300,0,312,105)];
backimage.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"popupj.png"]];
[backimage setUserInteractionEnabled:YES];
[cell addSubview:backimage];
}

I am calling this method on the button which is in cell i have used custom cell 

A:

You might try this, it may help you. 
-(IBAction)imageButtonAction:(id)sender{

    CustomCell *cell = (CustomCell *) [[sender superview] superview];
    UIButton *btn = (UIButton *)sender;
    for (UIView *subView in cell.contentView.subviews) {
        if([subView isKindOfClass:[UIView class]]){
            subView.hidden=YES;
        }
    }
    UIView *backimage = [[UIView alloc] initWithFrame:CGRectMake(300,0,312,105)];
    backimage.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"popupj.png"]];
    [backimage setUserInteractionEnabled:YES];
    [cell addSubview:backimage];
}

Or you can even use the block, to loop through subviews and hide them
Cheers

