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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:04:35+00:00 2026-06-17T08:04:35+00:00

I am using a custom UITableViewCell in my app, and I am trying to

  • 0

I am using a custom UITableViewCell in my app, and I am trying to adjust the frame of the “swipe to delete” button.

This is what I’m doing:

- (void)layoutSubviews {
    [super layoutSubviews];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) return;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:0.0f];
    for (UIView *subview in self.subviews) {
        if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
            CGRect newFrame = subview.frame;
            newFrame.origin.x = newFrame.origin.x - 25;
            subview.frame = newFrame;
        } else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
            CGRect newFrame = subview.frame;
            newFrame.origin.x = newFrame.origin.x - 25;
            subview.frame = newFrame;
        }
    }
}

It shows up in the new position, which is great. However, when I click away from the button so that it disappears, the button seems to suddenly move about 10 points to the left, and then gets removed.

Why is this happening, and how can I fix it?

  • 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-17T08:04:36+00:00Added an answer on June 17, 2026 at 8:04 am

    I’m not familiar with the animation code you’re using, but I would try using willTransitionToState (and, if needed, didTransitionToState) instead of layoutSubviews to handle animation during editing tableViewCells.

    Both have been available since iOS 3.0.

    Place this code in your subclass of UITableViewCell. It will handle all of the transitions from one UITableViewCellStateMask to another, and you can implement the animation you need for the transition to each state. Just implement the animations you require in the proper place according to the NSLogs I added. (again, not familiar with your animation code, but I did test it and saw results using this code)

    - (void)willTransitionToState:(UITableViewCellStateMask)state {
    
        [super willTransitionToState:state];
    
        if (state == UITableViewCellStateDefaultMask) {
    
            NSLog(@"Default");
            // When the cell returns to normal (not editing)
            // Do something...
    
        } else if ((state & UITableViewCellStateShowingEditControlMask) && (state & UITableViewCellStateShowingDeleteConfirmationMask)) {
    
            NSLog(@"Edit Control + Delete Button");
            // When the cell goes from Showing-the-Edit-Control (-) to Showing-the-Edit-Control (-) AND the Delete Button [Delete]
            // !!! It's important to have this BEFORE just showing the Edit Control because the edit control applies to both cases.!!!
            // Do something...
    
        } else if (state & UITableViewCellStateShowingEditControlMask) {
    
            NSLog(@"Edit Control Only");
            // When the cell goes into edit mode and Shows-the-Edit-Control (-)
            // Do something...
    
        } else if (state == UITableViewCellStateShowingDeleteConfirmationMask) {
    
            NSLog(@"Swipe to Delete [Delete] button only");
            // When the user swipes a row to delete without using the edit button.
            // Do something...
        }
    }
    

    And if you need something to happen after one of these events, just implement the same code, but in didTransitionToState. The same UITableViewCellStateMasks apply.

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

Sidebar

Related Questions

I am using a Custom UITableViewCell and this cell contains round rect. This round
The UITableView I am using has a custom UItableViewCell . This custom cell has
I'm creating custom UITableViewCells using the approach outlined on this page: http://icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/ So my
I'm trying to create a custom UITableViewCell with a XIB using MonoTouch/MonoDevelop. When I
I am using -drawRect for the first time in a custom UITableViewCell , and
I'm using DYRateView to display a star rating view in a custom UITableViewCell class.
I am using some custom fonts in my iphone app. They are displayed correctly,
I'm trying to add a custom delegate to a custom UITableViewCell of mine. On
I am using a custom UITableViewCell, which has some labels. There is one label
I'm trying to draw a line on a custom UITableViewCell. When I draw inside

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.