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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:18:44+00:00 2026-05-28T19:18:44+00:00

I have a UItableView I can add and delete cells. I can change the

  • 0

I have a UItableView I can add and delete cells. I can change the cell.textLabel.text properties. If i add 13 to my cell.textLabel.text…

enter image description here

and if i delete the TOP cell, that cell’s textLabel get set to the cell that moved up on the table…

enter image description here

How can i fix this? I want to be able to delete a cell and have it keep its own textLabel. Here is my cellForRow method if its needed:

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

    cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil)
     {
         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];

         addBtn = [[UIButton alloc]init];
         addBtn =[UIButton buttonWithType:UIButtonTypeRoundedRect];
         [addBtn setFrame:CGRectMake(220,10,25,55)];
         [addBtn addTarget:self action:@selector(addLabelText:) forControlEvents:UIControlEventTouchUpInside];
         [addBtn setTitle:@"+" forState:UIControlStateNormal];
         [addBtn setEnabled:YES];
         [cell addSubview:addBtn];

         subBtn = [[UIButton alloc]init];
         subBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
         [subBtn setFrame:CGRectMake(260,10,25,55)];
         [subBtn addTarget:self action:@selector(subtractLabelText:) forControlEvents:UIControlEventTouchUpInside];
         [subBtn setTitle:@"-" forState:UIControlStateNormal];
         [subBtn setEnabled:YES];
         [cell addSubview:subBtn];
     } 
    //cellText.hidden=!self.editing;
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.imageView.image = [imageArray objectAtIndex:indexPath.row];  
    cell.tag = indexPath.row; // Important for identifying the cell easily later
    cell.textLabel.text = [self.number objectAtIndex:indexPath.row];

return cell;
}

Thanks in advance for any 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-28T19:18:45+00:00Added an answer on May 28, 2026 at 7:18 pm

    When you delete a cell your UITableView and all the cells in it get redrawn. At the time the cell is deleted you need to delete the corresponding object from your data source also (in your case, the array self.number) so that the objects in your data source array correspond to the new indexes of the table cells.

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

Sidebar

Related Questions

I have a UITableView and i can add and delete cells. I also have
Ok i have a table view that can add and delete cells. For each
I have a UITableView and its a checklist. I can add new cells to
I'm attempting to have a UITableView that I can dynamically add and remove rows
Can you add a button as a subview to a uitableview cell and have
In an app I'm working on, I have a plain style UITableView that can
Can I have that A-Z index bar in an UITableView also with UITableViewStyleGrouped, or
I have a UITableView cell that is going to have a variable size depending
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

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.