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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:17:55+00:00 2026-05-22T17:17:55+00:00

In my UITableview, I am receiving a strange error. I have an array of

  • 0

In my UITableview, I am receiving a strange error. I have an array of dictionaries named _cellTextArray, and that dictionary contains the keys “textLabel”, “detailTextLabel” and “cornerLabel”. However I created three UILabel’s which are added to the contentView of the cell and their text is set to their corresponding name in the dictionary. My problem is that the textLabels are only retrieving the first 5 objects in the dictionary, and using them for every cell rather than retrieving the object at the index of the cell in the dictionary.

Please could you tell me what I am doing wrong. I have combed through the code a few times, NSLog’ing the dictionaryValues for each indexPath, and they are all correct.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CustomCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    CheckBox *btn = (CheckBox *)[_checkboxArray objectAtIndex:indexPath.row];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        [cell.contentView addSubview:btn];
        //I added this code:
        cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:12.0];
        cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
        cell.textLabel.numberOfLines = 3; // 0 means no max.


        UIImageView* img = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gradient7.png"]] autorelease];
        [cell setBackgroundView:img];

        UILabel *lab = [[[UILabel alloc] initWithFrame:CGRectMake(40, 18, cell.contentView.frame.size.width-15, 22)] autorelease];
        [lab setText:[[_cellTextArray objectAtIndex:indexPath.row] objectForKey:@"textLabel"]];
        [lab setBackgroundColor:[UIColor clearColor]];
        [lab setTextColor:[UIColor whiteColor]];
        [lab setAdjustsFontSizeToFitWidth:YES];
        [lab setTextAlignment:UITextAlignmentLeft];
        [cell.contentView addSubview:lab];

        UILabel *dlabl = [[[UILabel alloc] initWithFrame:CGRectMake(5, 54, cell.contentView.frame.size.width- 1, 22)] autorelease];
        [dlabl setText:[[_cellTextArray objectAtIndex:indexPath.row] objectForKey:@"detailTextLabel"]];
        [dlabl setTextColor:[UIColor colorWithRed:1.0 green:0.80 blue:0.0 alpha:1.0]];
        [dlabl setBackgroundColor:[UIColor clearColor]];
       // [dlabl setAdjustsFontSizeToFitWidth:YES];
        [dlabl setTextAlignment:UITextAlignmentLeft];
        [dlabl setFont:[UIFont systemFontOfSize:[lab font].pointSize - 3]];
        [cell.contentView addSubview:dlabl];

        UILabel *cornerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(cell.contentView.frame.size.width - 40, 19, 40, 20)] autorelease];
        [cornerLabel setTextColor:[UIColor whiteColor]];
        //[cornerLabel setFont:[UIFont systemFontOfSize:12]];
        [cornerLabel setAdjustsFontSizeToFitWidth:YES];
        [cornerLabel setBackgroundColor:[UIColor clearColor]];
        [cornerLabel setTextAlignment:UITextAlignmentCenter];
        [cell.contentView addSubview:cornerLabel];
        [cornerLabel setAdjustsFontSizeToFitWidth:YES];
        [cornerLabel setText:[[_cellTextArray objectAtIndex:indexPath.row] objectForKey:@"cornerLabel"]];

        // Adds image to cell
      //  UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(100, 5, 140, 50)] autorelease];
     //   [imageView setImage:[UIImage imageNamed:[[_cellTextArray objectAtIndex:indexPath.row] objectForKey:@"image"]]];
     //   [cell.contentView addSubview:imageView];            
    }
    // Configure the cell.
    return cell;
}
  • 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-22T17:17:55+00:00Added an answer on May 22, 2026 at 5:17 pm

    Check Listing 5-3 on this page (iOS Table View Programming Guide) to see how it is done properly.

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

Sidebar

Related Questions

I have a UITableView cell that is going to have a variable size depending
I have a UITableView which is populated by an array, I have a button
I have a UITableView that displays single large images in each cell. The names
I have a uitableview that loads fairly large images in each cell and the
I have a UITableView that gets populated from CoreData via a controller that implements
I have a UITableView containing names that I would like to group (and sort)
I have a UITableView that I have set-up with 2 sections. The code below
I have a UITableView that I populate with data that i download over the
I have a UITableView that has a disclosure button on every row. When the
I have a UITableView that loads content into a UIWebView like this: //MainViewController.m -

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.