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 6364489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:10:11+00:00 2026-05-25T00:10:11+00:00

I have trouble when I add subviews to UITableViewCell. It’s working when the table

  • 0

I have trouble when I add subviews to UITableViewCell.
It’s working when the table size is below the iPhone size.

But when the size is bigger, it makes some horrible effect like this when I’m scrolling :

enter image description here

It’s supposed to be like this :

enter image description here
Then I think it comes from the cell reuse.
Here is a sample of my code :

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

    static NSString *kCellIdentifier = @"UITableViewCellStyleSubtitle";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
    if (cell == nil) {
        //construct the cell
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                       reuseIdentifier:kCellIdentifier] autorelease]; 


        //clear the previuous content
        NSLog(@"Il y a %d subviews", [[[cell contentView] subviews] count]);
        //[[[cell contentView] subviews] makeObjectsPerformSelector: @selector(removeFromSuperview)];
        NSLog(@"Il y a %d subviews", [[[cell contentView] subviews] count]);
        [[cell textLabel] setBackgroundColor:[UIColor clearColor]];
        [cell setSelectionStyle:UITableViewCellEditingStyleNone];
    }    

    switch (indexPath.row) {
        case 0:
            [cell addSubview:titleEvent];
            break;
        case 1:
            //load the owner logo
            [cell addSubview:logoAsso];
            break;
        case 2:
            //StartDate
            [cell addSubview:clockImage];
            break;
        case 3:
            //EndDate
            [cell addSubview:clockEndImage]; 
            break;
        case 4:
            //Address
            [cell addSubview:adress];
            break;
        case 5:
            //map
            [cell addSubview:map];
            break;
        case 6:
            //header
            [Graphism configureSeparationCell:cell];
            break;
        case 7:
            //descritpion
            [cell addSubview:descriptionEvent];
            break;
        default:
            break;
    }
    return cell;
}

The subviews are attributs of the class, and configured in the method viewDidLoad.
If you can tell me what i’m doing wrong, that would be such a relief.

  • 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-25T00:10:12+00:00Added an answer on May 25, 2026 at 12:10 am
    switch (indexPath.row) {
        case 0:
    
    
            if (![cell.contentView viewWithTag:11]) {
    
                titleEvent.tag = 11;
    
                [cell.contentView addSubview:titleEvent];
            }
    
    
            break;
        case 1:
            if (![cell.contentView viewWithTag:11]) {
    
                logoAsso.tag = 11;
    
                [cell.contentView addSubview:logoAsso];
            }
    

    like this do for all switch cases

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

Sidebar

Related Questions

I'm trying to add a UIButton to a UIView, but am having some trouble
I have trouble doing this. I'm creating a method that add working days on
I have trouble where, for some reason, SVN would only merge the newly generated
I have some trouble with a core data project. I have a NSArrayController with
Hello I have a trouble customizing a background of the grouped table view.. Here's
I'm having some trouble getting a view to flip. I have the following code
Hey guys, I'm getting a little trouble here. I have a view that makes
I always have trouble with Java layouts, but the main thing bugging me now
I have a very simple django site but I have trouble getting the images
I am trying to customize the UITableViewCell below for an iPhone app in a

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.