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

  • Home
  • SEARCH
  • 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 5972271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:38:04+00:00 2026-05-22T20:38:04+00:00

hi all i implemented customized UITableViewcell with the below code.Each cell loaded with four

  • 0

hi all i implemented customized UITableViewcell with the below code.Each cell loaded with four images..

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *hlCellID = @"hlCellID";

UITableViewCell *hlcell = [tableView dequeueReusableCellWithIdentifier:hlCellID];
if(hlcell == nil) {
    hlcell =  [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:hlCellID] autorelease];
    hlcell.accessoryType = UITableViewCellAccessoryNone;
    hlcell.selectionStyle = UITableViewCellSelectionStyleNone;
    [hlcell.contentView removeAllSubViews];


}
//NSLog(@"the scetions is %@",sections);

int section = indexPath.section;


for(int i=0;i<4;i++){


    CGRect rect = CGRectMake(18+192*i, (4*indexPath.row)+50, 120, 150);

    if ((4*indexPath.row)+i>=[self.imagesToDisplay count]) {
        break;
    }
    UIImage *imageToDisplay=[UIImage imageWithData:[self.imagesToDisplay objectAtIndex:(4*indexPath.row)+i]];
    NSLog(@"The size of the image is:%@",NSStringFromCGSize(imageToDisplay.size));
    UIButton *button=[[UIButton alloc] initWithFrame:rect];
    [button setFrame:rect];

    [button setBackgroundImage:imageToDisplay   forState:UIControlStateNormal];
    [button setContentMode:UIViewContentModeCenter];

    NSString *tagValue = [NSString stringWithFormat:@"%d%d",indexPath.row,i];
    NSLog(@"the tag is %@",tagValue);
    button.tag = [tagValue intValue];
    NSLog(@"....tag....%d", button.tag);
    [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [hlcell.contentView addSubview:button];
    [button release];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(18+192*i,(4*indexPath.row)+100+70 , 100, 100)] ;
    label.text = @"price $0.99";
    label.textColor = [UIColor blackColor];
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = UITextAlignmentCenter;
    label.font = [UIFont fontWithName:@"ArialMT" size:12]; 

    [hlcell.contentView addSubview:label];
    [label release];


}


return hlcell;

}

for each image acts as uibutton.i am trying to load around 1000 images.these images i am taking from the server.when one image is loaded to my app i am updating total cell.

NSIndexPath *indexPath=[NSIndexPath indexPathForRow:ceil((float)[gridView.imagesToDisplay count]/4)-1 inSection:0];
NSArray *cellIndexPath=[NSArray arrayWithObjects:indexPath,nil];
[gridView.tableview reloadRowsAtIndexPaths:cellIndexPath withRowAnimation:UITableViewRowAnimationNone];

upto now my code is working fine and when i am trying to scroll many times after loading all the images its getting crash.and my GDB showing as memory warning.can any one suggest me why the issue happening.Thanks for your response in advance.

  • 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-22T20:38:05+00:00Added an answer on May 22, 2026 at 8:38 pm

    It looks like you always allocate new Images and display them on the Cell, but you never actually release the images when the cell is no longer displayed.

    The definition for the UITableView cell states, that as soon a cell is no longer used it is purged and prepared for a new content. In your code you always add new subviews to the cell, but never actually release the content.

    The best solution to your problem is to implement a UITableViewCell by subclassing it and manually set the images. Furthermore implement the

    - (void)prepareForReuse
    

    method of the class to release the images that are currently displayed. See the reference for more documentation of UITableViewCell

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

Sidebar

Related Questions

i have implemented keylistener interface and implemented all the needed methods but when i
Here is my implementation in summary 1) all DAOs implemented using HibernateDAO support/ @Transational
I took a data structures class in C++ last year, and consequently implemented all
Is it possible to return a list of all the properties implemented by an
Backgroup: We are looking at SAS BI Dashboard. We have currently implemented almost all
I have implemented VirtualPathProvider class so I can keep all my views in the
I implemented a fonction in Visual Basic 2008 that takes the content of all
I implemented threading in my application for scraping websites. After all the sites are
We all know what virtual functions are in C++, but how are they implemented
I've implemented a slideshow using the Cycle plugin, which is working in all browsers

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.