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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:03:22+00:00 2026-06-18T06:03:22+00:00

Okay, so my issue is that I’m deleting rows in a tableview upon a

  • 0

Okay, so my issue is that I’m deleting rows in a tableview upon a click on a button, and I’m identifying the row to delete by getting the sender’s tag and removing it from my data source array and deleting the row from the table…

In cellForRowAtIndexPath (relevant part is deleteBtn): *BELOW IS THE FIXED AND WORKING CODE

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

    HTQuestionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

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

    NSDictionary *dict = [NSDictionary dictionary];
    dict = _questionsArray[indexPath.row];

    NSMutableAttributedString *atbString;
    NSMutableAttributedString *atbQuestionString;

    atbString = [[NSMutableAttributedString alloc] initWithString:[dict objectForKey:@"person"] attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:34]}];

    atbQuestionString = [[NSMutableAttributedString alloc] initWithString:[dict objectForKey:@"question"] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:34]}];

    [atbString appendAttributedString:atbQuestionString];

    [cell.questionTxtView setAttributedText:atbString];

    [cell.deleteBtn setTag:indexPath.row];
    [cell.showBtn setTag:indexPath.row];

    NSLog(@"Delete Button : %@", cell.deleteBtn);

    [cell.deleteBtn addTarget:self action:@selector(deleteMsg:) forControlEvents:UIControlEventTouchUpInside];
    [cell.showBtn addTarget:self action:@selector(showMsg:) forControlEvents:UIControlEventTouchUpInside];

    return cell;
}

And in the delete method I then do this:

UIButton *tempButton = sender;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:tempButton.tag inSection:0];
[_questionsArray removeObjectAtIndex:tempButton.tag];
[_dataTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[_dataTable reloadData];

I’ve also tried with beginUpdates and endUpdates instead of reloadData, but none have any effect…

So, when I’m testing it, I have two rows… Initially their tag’s get set correctly – 0 and 1… But when I then delete row 0, and check the tag for the new first row, it still has the tag = 1, when it now should be 0… It’s almost like it doesn’t update the button’s tag after the deletion…

  • 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-18T06:03:23+00:00Added an answer on June 18, 2026 at 6:03 am

    Solution 1: use:

    [_dataTable reloadData];
    

    to reset the tags, as cellForRowAtIndexPath is called again

    Solution 2: use:

    [_dataTable beginUpdates];
    [_dataTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    [_dataTable endUpdates];
    

    which will also call cellForRowAtIndexPath and update the tags

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

Sidebar

Related Questions

Okay, so my issue is that I have to catch delete and rename events
Okay, so the issue I'm being stuck at for few days already is that
Okay...I'm really getting a bit frustrated with this. I know that this post will
Okay, so my issue is that i have alot of programs that i am
**Okay, It's become clear that this issue is an issue related with the setup
Okay, I have an issue using Knockout in that it isn't able to parse
Okay here's my issue. I have a block that is 348px wide, and on
Okay so here my issue, I have a list of items that when a
Okay, so here's the issue. I have two apps that need to package up
I'm having a bizarre issue that I haven't seen before and I'm thinking it

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.