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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:44:13+00:00 2026-05-25T13:44:13+00:00

In a UITableView I add a UIView as subview but ONLY for section 1.

  • 0

In a UITableView I add a UIView as subview but ONLY for section 1. Section 1’s content is loaded from a plist and the plist contains mutable content. If there are enough rows to allow scrolling, then the following happens: I scroll to the bottom, and back up, and the UITextField appears randomly on some of section 0’s cells. I have no clue why this is happening! So what i do is this (in ´cellForRowAtIndexPath´):

if (indexPath.section == 0) {
    //do stuff
}
else if (indexPath.section == 1) {
    d = [UIView alloc] init];
    [cell.contentView addSubview:d];
}

and this gets totally messed up when I scroll. The subviews appear in section 0 where they shoudnt, and on didSelectRowAtIdexPath I reload for section 1 and then subviews even appear twice (over each other)… Its a complete MESS! Please, Please help…….

  • 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-25T13:44:14+00:00Added an answer on May 25, 2026 at 1:44 pm

    Without seeing any code this seems to be an issue pertaining to reusable cells. What happens is that the cells that have scrolled off the screen are reused for the new content that is to be shown. So i reckon you need to make a distinction in cellForRowAtIndexPath for section 0 and 1 and basically use different set of cells for them.

    EDIT: Ok ima give a shot to your problem here

    UITableViewCell *cell;
    
    if (indexPath.section == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:@"CellWithoutSubview"];
        if (cell ==nil ) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewStylePlain reuseIdentifier:@"CellWithoutSubview"] autorelease];
        }
    
        //do stuff with cell like set text or whatever
    }
    else if (indexPath.section == 1) {
        cell = [tableView dequeueReusableCellWithIdentifier:@"CellWithSubview"];
        if (cell ==nil ) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewStylePlain reuseIdentifier:@"CellWithSubview"] autorelease];
    
            d = [[UIView alloc] init];
            [cell.contentView addSubview:d];
            [d release];
        }
    
    
    }
    
    return cell;
    

    So now you’ll have two types of cells for the tableview that’ll be reused one without the subview and one with the subview.

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

Sidebar

Related Questions

I have an UIView high 30, than i add an UITableView as subview with
I'm wondering if it is possible to add cell content to a uitableview based
I have UITableView and it add data from NSMutableArray. So, I want to know
I have a UITableView and I want to add a UIView as a footer.
I have a UIView that contains your typical UITableView with a UISearchBar. It seems
A UITableview inherits from a UIScrollview. But, if u want a UITableview within a
I've created a custom UIView, and inside that UIView, I add a UITableView like
How can I add an UIView as a subview in a cells contentView when
I'm trying to add a UIView on top over the UITableView to mimic the
I'm using custom headers for my tableview... - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { CustomHeaderController

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.