Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6580191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:59:42+00:00 2026-05-25T15:59:42+00:00

i am working on one application in which i have created one table view

  • 0

i am working on one application in which i have created one table view using custom cell.In custom cell i have added imageview.i am parsing images from server and add that images to tableview now when user press on delete button i want to reload tableview data but the problem is that previously added subviews are not released.I also use code for release it but it not works.
Here is sample code and image of tableview

if (buttonIndex == 0)
{       
    [images removeObjectAtIndex:selectedImage];

    for(id object in [self.view subviews])
    {
        [object removeFromSuperview];
    }
    //for (UIImageView *aLabel in [tv subviews]) [aLabel removeFromSuperview];

    [self.myTableView reloadData];
}

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:59:43+00:00Added an answer on May 25, 2026 at 3:59 pm

    Inside your “cellForRowAtIndexPath” table method, put below code before you add the image subview.

    UIImageView *img = nil;
    NSArray *Array = [cell subviews];
    for (img in Array){
        if ([img isKindOfClass:[UIImageView class]]){
            [img removeFromSuperview];
        }
    }
    

    Also “cell” should be initialize once.

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    

    CGFloat xcord_img,ycord_img,height_img,width_img;    
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    UIImageView *img = nil;
    NSArray *Array = [cell subviews];
    for (img in Array)
    {
        if ([img isKindOfClass:[UIImageView class]]){
            [img removeFromSuperview];          
         }
    }
    UIButton *btn = nil;
    NSArray *Array1 = [cell subviews];
    for (btn in Array1){
        if ([btn isKindOfClass:[UIButton class]]){
            [btn removeFromSuperview];
        }
    }
    
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    space_img = 100;
    xcord_img = 20;
    ycord_img = 20;
    height_img = 70;
    width_img = 70;
    int i=0; 
    
    
    for(int j=0; j<rownum && indexPath.row*rownum+j<18; 
    {
        NSString *tagValue = [NSString stringWithFormat:@"%d", indexPath.row*rownum+j];
    
    magazineData *obj=[[magazineData alloc]init];
    obj=[mData objectAtIndex:indexPath.row];
    
    UIImage *imgs=[UIImage imageWithData:obj.mImage]; 
    UIImageView *ImagesVw = [[UIImageView alloc] initWithImage:imgs];
    ImagesVw.frame=CGRectMake(xcord_img+space_img*j, ycord_img, width_img, height_img);
    UIButton *button = [[UIButton alloc] initWithFrame:ImagesVw.frame];
    button.tag = [tagValue intValue];
    [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor= [UIColor clearColor];
    //[cell.contentView addSubview:button];
    //[button release];
    [cell addSubview:button];
    //[cell.contentView addSubview:ImagesVw];      
    [cell addSubview: ImagesVw];
    [cell bringSubviewToFront: ImagesVw];
    
    //[ImagesVw release];
    i++;
    }
    

    return cell;

    Hi have updated code. Please review it.

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on one application in which i have added 5 labels dynamically
hello i have created one windows application in c# .net and its working fine
Im using c# .net windows form application. I have created a database which has
I am working on an application in which one module accesses a log (an
I have a small application I am working on that at one point needs
I am working on a WinForms application in C#. I initially have a Table
I am developing an application using oracle 11g, Java(struts2) and Hibernate. I have table
I have a working web application which already has a login and registration system.
I'm currently working on an Intranet application project, using ASP.NET MVC 3. One of
I am working on an application (using the spring framework) in which current time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.