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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:19:34+00:00 2026-06-17T16:19:34+00:00

In my uitableview I have two sections first is fetched from core data other

  • 0

In my uitableview I have two sections

first is fetched from core data

other is added through textfield which is stored in NSMutableArray(otherFriends)

here is my code

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if([otherFriends count]>0)
    {
        return 2;
    }
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
    if(otherFriends == 0)
    {
        return [[[[self fetchedResultsController]sections]objectAtIndex:0]numberOfObjects];
    }
    return [otherFriends count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"newGroupCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }

    cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Light" size:20.0];
    cell.textLabel.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.0f];

    if(indexPath.section == 0)
    {
        user = [[self fetchedResultsController] objectAtIndexPath:indexPath];

        cell.textLabel.text = user.name;
        cell.detailTextLabel.text = user.primaryResource.status;

        [cell.imageView setFrame:CGRectMake(0, 0, 50, 50)];
        [cell.imageView.layer setMasksToBounds:YES];

        if (user.photo != nil)
        {
            cell.imageView.image = user.photo;
        }
        else
        {
            cell.imageView.image = [UIImage imageNamed:@"defaultPerson"];
        }
    }
    else
    {
        cell.textLabel.text = [otherFriends objectAtIndex:indexPath.row];
        cell.imageView.image = [UIImage imageNamed:@"defaultPerson"];
    }

    return cell;
}

First section also have subtitles but second section cells have no subtitles

when I am adding new friend it works fine till all rows are visible, but when adding new friend and that row is not visible and to view that row I must scroll, then this row show the subtitle of first row in section 0(the very first cell) and its repeating in section 1 third row. Only subtitle is repeating but the main text is not.

For several hours I am trying to figure out this but no luck.

  • 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-06-17T16:19:36+00:00Added an answer on June 17, 2026 at 4:19 pm

    This is because in your else branch you are not setting the cell.detailTextLabel.text.

    When a cell gets recycled, the old detailTextLabel stays there. You need to set all properties of the cell in both branches of the conditionsl, on the chance that it has been recycled.

    if(indexPath.section == 0)
    {
        user = [[self fetchedResultsController] objectAtIndexPath:indexPath];
    
        cell.textLabel.text = user.name;
        cell.detailTextLabel.text = user.primaryResource.status;
    
        [cell.imageView setFrame:CGRectMake(0, 0, 50, 50)];
        [cell.imageView.layer setMasksToBounds:YES];
    
        if (user.photo != nil)
        {
            cell.imageView.image = user.photo;
        }
        else
        {
            cell.imageView.image = [UIImage imageNamed:@"defaultPerson"];
        }
    }
    else
    {
        cell.textLabel.text = [otherFriends objectAtIndex:indexPath.row];
        cell.imageView.image = [UIImage imageNamed:@"defaultPerson"];
        // ADDED
        cell.detailTextLabel.text = @"";
        // You may also need to adjust the frame of the cell.imageView
        // because it could have been recycled.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my 'Sectioned' UITableView I have two sections, the first one for Attributes like
I have an instance of UITableView with two sections, the first with one row
I have two tableView sections, sometimes the first section dosen't have any data in
I have a UITableViewController which has two sections. The first section shows a single
I have a simple UITableView with two sections. Each section has a header which
I have a UITableView With Two Sections. First section has one row and the
I have one problem with two sections in UITableview grouped style. First section having
I have two UITableview. The first one shows 3 sections with 3 row each
Suppose I have a UITableView with two sections. If the data source for that
I have a Core Data stack in which there are two entities: 'Client' and

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.