UITableViewCell delete button gets covered up

后端 未结 12 1878
闹比i
闹比i 2020-12-01 08:55

UPDATE:

Thanks to information from \"Evgeny S\" I\'ve been able to determine that what is covering up the delete button is the cell background. I had the following f

相关标签:
12条回答
  • 2020-12-01 08:58

    Cleaner, General Solution

    Assuming an iOS7 only app, with a technique similar to that posted by chris above, I believe the approach here: https://stackoverflow.com/a/19416870/535054 is going to be cleaner.

    In this approach, you don't need to subclass your backgroundView, which could be different for different cells.

    Place the code in the answer I've linked to above, in the root of your custom table cell hierarchy, and all of your table cells (that inherit from it), get the fix whenever they use the backgroundView or selectedBackgroundView properties.

    0 讨论(0)
  • 2020-12-01 08:59

    I've run into a similar problem and have a work around the that puts the Delete button on top of my cell content but the animation is a bit ugly. When done the button is visible and does the right thing.

    Create a custom subclass of UITableViewCell and add the following code:

    -(void)didTransitionToState:(UITableViewCellStateMask)state
    {
        if (state & UITableViewCellStateShowingDeleteConfirmationMask ) {
            [self sendSubviewToBack:self.contentView];
    
        }
    
        [super didTransitionToState:state];
    }
    

    Improvements on this approach or other pointers would be appreciated.

    0 讨论(0)
  • 2020-12-01 09:02

    I fixed this by finding the delete button view and bringing it to the front. I did this in layoutSubviews in a UITableViewCell subclass.

    Here's a small bit of code that should give you an idea of how to do it:

    - (void)layoutSubviews
    {
        [super layoutSubviews];
    
        for (UIView *subview in self.subviews) {
    
            for (UIView *subview2 in subview.subviews) {
    
                if ([NSStringFromClass([subview2 class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) { // move delete confirmation view
    
                [subview bringSubviewToFront:subview2];
    
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-01 09:07

    I was facing an issue where my UITableView was in editing mode and after deleting 2-3 rows I get message "attempting to set a swipe to delete cell when we already have one....that doesn't seem good" logged and then user Interaction on all cells except one cell gets disabled.

    I solved this issue by

    [myTableView setEditing:NO animated:NO];
    [myTableView setEditing:YES animated:NO];
    

    after each deletion.

    This workaround worked in my case.

    0 讨论(0)
  • 2020-12-01 09:08

    And one more workaround:

    - (void) layoutSubviews {
        [super layoutSubviews];
    
        if ([ [ [UIDevice currentDevice] systemVersion] compare: @"7.0" options: NSNumericSearch] != NSOrderedAscending) {
            if (iOS7 == YES) {
                self.backgroundView.frame = CGRectMake(0, self.backgroundView.frame.origin.y,
                                                       self.backgroundView.frame.size.width, self.backgroundView.frame.size.height);
        }
    }
    
    0 讨论(0)
  • 2020-12-01 09:10
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        [self sendSubviewToBack:self.contentView];
    }
    
    0 讨论(0)
提交回复
热议问题