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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:54:44+00:00 2026-05-30T22:54:44+00:00

I want to be able to hide a label in my UITableViewCell in order

  • 0

I want to be able to hide a label in my UITableViewCell in order to stop it from overlapping with the title whenever a user swipes to delete a cell.

I’m using the following code to initiate and handle the swipe to delete:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {

        [self.tableView beginUpdates]; // Avoid  NSInternalInconsistencyException

        // Delete the project object that was swiped
        Project *projectToDelete = [self.fetchedResultsController objectAtIndexPath:indexPath];
        NSLog(@"Deleting (%@)", projectToDelete.name);
        [self.managedObjectContext deleteObject:projectToDelete];
        [self.managedObjectContext save:nil];

        // Delete the (now empty) row on the table
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
        [self performFetch];

        [self.tableView endUpdates];
    }
}

I’ve assigned the label in the cell using:

UILabel *projectDate = (UILabel *)[cell viewWithTag:3];
    projectDate.text = project.dateStarted;

And have tried just setting

projectDate.hidden = YES; 

however, this does not work.

  • 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-30T22:54:45+00:00Added an answer on May 30, 2026 at 10:54 pm

    I think you’ll need to subclass UITableViewCell to implement this. In the subclass override - (void) setEditing:(BOOL)editing animated:(BOOL)animated. In this method you can hide the label. If you only need to hide the label for delete operations, then use self.editingStyle to conditionally hide the label depending on the editing style (aka: UITableViewCellEditingStyleDelete).

    Here are two examples. I prefer example two, it’s easier. But example one will let you replace text, which might be useful:

    @implementation CellSubclass{
        NSString *_labelText; //only used in example 1
    }
    
    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            // Initialization code
        }
        return self;
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated{
        [super setSelected:selected animated:animated];
    
        // Configure the view for the selected state
    }
    // Example 1, replacing the text value
    - (void) setEditing:(BOOL)editing animated:(BOOL)animated{
        [super setEditing:editing animated:animated];
        if (editing && self.editingStyle == UITableViewCellEditingStyleDelete){
            UILabel *label = (UILabel *)[self viewWithTag:3];
            _labelText = label.text;
            self.textLabel.text = nil;
        }  else if (!editing && _labelText){
            UILabel *label = (UILabel *)[self viewWithTag:3];
            label.text = _labelText;
        }
    }
    
    //Example 2 - hiding the view itself
    - (void) setEditing:(BOOL)editing animated:(BOOL)animated{
        [super setEditing:editing animated:animated];
        if (editing && self.editingStyle == UITableViewCellEditingStyleDelete){
            [self viewWithTag:3].alpha = 0.0f;
        } else {
            [self viewWithTag:3].alpha = 1.0f;
        }
    }
    
    @end
    

    Please, please note that I have two methods with the same name. That obviously is a big no-no….use only one of them.

    Also note that I ignored the animated parameter. If you want the disappearance of your label to be animated in the second example (aka…fade away/fade in) all you need to do is surround your changes in an animation block, like so:

            [UIView animateWithDuration:.3f animations:^{
                [self viewWithTag:3].alpha = 0.0f;
            }]; 
    

    I don’t think you can animate the first example.

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

Sidebar

Related Questions

I want to be able to delete a user from my DB. The interface
Thanks to some help from a user here I was able to hide my
I want to be able to email a report daily from a glpi database
I want to be able to invoke an SSIS package at will from a
I want to be able to strip off a header from a wav file.
I want to show and hide a label and its control. I can do
I want to be able to hide an entire container when I check a
Hi i just want to be able to toggle to hide/show a div respectively
I'm new to MVC. I want to be able to hide some actionlinks for
I want to be able to hide the header at the top of each

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.