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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:56:29+00:00 2026-06-06T03:56:29+00:00

I have a UITableView with regular UITableViewCell, but I don’t use any of UITableViewCell’s

  • 0

I have a UITableView with regular UITableViewCell, but I don’t use any of UITableViewCell’s lables. I just use the cell to embed a label and a UITextField to input some data. Problem is when you scroll up or scroll down and the UITableviewCell redraws itself, it draws an overlapping UITextFieldView over the old one and you see doubles! I’m thinking that maybe since I do put these UITextFields into a dictionary, it might save the textfield with a strong pointer, and try to make another one and just overlap. Anyone have any suggestions?

Here is my code:

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

NSDictionary *product = [self.products objectAtIndex:indexPath.row];
NSDictionary *orderpoint = [self.orderpoints objectAtIndex:indexPath.row];

cell.textLabel.text = @""; //black out text

CGFloat calculatedHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
UILabel *productLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, cell.bounds.size.width - 50.0, calculatedHeight)];

productLabel.text = [[NSString alloc] initWithFormat:@"%@. %@",
                       [orderpoint objectForKey:@"sequence_nr"], [product objectForKey:@"name"]];
//word wrapping
productLabel.lineBreakMode = UILineBreakModeWordWrap;
productLabel.numberOfLines = 0; //infinite number of lines
productLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0];

[cell.contentView addSubview:productLabel];

 //create the cell's textfield
UITextField *cellTextField = [[UITextField alloc] initWithFrame:CGRectMake(cell.bounds.size.width - 50, cell.bounds.size.height - 30, 50, calculatedHeight - 20)];
cellTextField.adjustsFontSizeToFitWidth = YES;
cellTextField.textColor = [UIColor blackColor];
cellTextField.keyboardType = UIKeyboardTypeNumberPad; // will only need to end a count
cellTextField.returnKeyType = UIReturnKeyDone; // TODO make it go to the next items key, or make it exit out
cellTextField.backgroundColor = [UIColor whiteColor];
cellTextField.textAlignment = UITextAlignmentLeft; //align to the right
//cellTextField.delegate = self; //will need to set delegate, maybe
cellTextField.clearButtonMode = UITextFieldViewModeNever;
cellTextField.enabled = YES;
cellTextField.borderStyle = UITextBorderStyleRoundedRect; //add bezel rounded look to textfield
cellTextField.delegate = self;

[cell.contentView addSubview: cellTextField]; //add the textfield to the cell
// save to dictionary, using a dictionary because not certain if this is created in order to use an Array
[self.textFieldDict setObject:cellTextField forKey:[[NSNumber alloc] initWithInteger:indexPath.row]];

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-06-06T03:56:31+00:00Added an answer on June 6, 2026 at 3:56 am

    Used this as a reference: add subviews to UITableViewCell

    I just first checked to see if this view was added from before, and if it was, then don’t add it again. It has nothing to do with the cell being nil. Unless I missed something? all I know is that this seems to be working fine, now.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *CellIdentifier = @"ProductCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    NSDictionary *product = [self.products objectAtIndex:indexPath.row];
    NSDictionary *orderpoint = [self.orderpoints objectAtIndex:indexPath.row];
    
    cell.textLabel.text = @""; //black out text
    
    CGFloat calculatedHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
    UILabel *productLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, cell.bounds.size.width - 50.0, calculatedHeight)];
    
    productLabel.text = [[NSString alloc] initWithFormat:@"%@. %@",
                           [orderpoint objectForKey:@"sequence_nr"], [product objectForKey:@"name"]];
    //word wrapping
    productLabel.lineBreakMode = UILineBreakModeWordWrap;
    productLabel.numberOfLines = 0; //infinite number of lines
    productLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0];
    
    [cell.contentView addSubview:productLabel];
    
    if (![cell viewWithTag:1])
    {
        //create the cell's textfield
        UITextField *cellTextField = [[UITextField alloc] initWithFrame:CGRectMake(cell.bounds.size.width - 50, cell.bounds.size.height - 30, 50, calculatedHeight - 20)];
        cellTextField.adjustsFontSizeToFitWidth = YES;
        cellTextField.textColor = [UIColor blackColor];
        cellTextField.keyboardType = UIKeyboardTypeNumberPad; // will only need to end a count
        cellTextField.returnKeyType = UIReturnKeyDone; // TODO make it go to the next items key, or make it exit out
        cellTextField.backgroundColor = [UIColor whiteColor];
        cellTextField.textAlignment = UITextAlignmentLeft; //align to the right
        cellTextField.delegate = self; //will need to set delegate, maybe
        cellTextField.clearButtonMode = UITextFieldViewModeNever;
        cellTextField.enabled = YES;
        cellTextField.borderStyle = UITextBorderStyleRoundedRect; //add bezel rounded look to textfield
        cellTextField.delegate = self;
    
        cellTextField.tag = 1; //set tag to 1
    
        [cell.contentView addSubview: cellTextField]; //add the textfield to the cell
        // save to dictionary, using a dictionary because not certain if this is created in order to use an Array
        [self.textFieldDict setObject:cellTextField forKey:[[NSNumber alloc] initWithInteger:indexPath.row]];
    }
    
    return cell;
    

    }

    • 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 with several UITextField s in it. When a user
I have just a regular UITableView, and I ran this code: UITableView *tableView =
I have a regular UITableViewController and a UITableView as its only view, and I
I have UITableView that contains many cell. User can expand cell to see more
I have UITableView and cell's are customized and have a UIImage with UIbutton, UIlabel
I have a regular-style UITableView—the one that has a white background and gray horizontal
There is any way to get cell coordinates when pressing on cell? I have
I have an UITableView and I want to detect double touches on UITableViewCell. I
I have a UITableView with pagingEnabled. Each cell takes up the viewing area of
I have a UITableView with custom background images in each cell. The bottom cell

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.