How can I animate the dismissal of a UITableView swipe-to-delete button?

后端 未结 3 682
醉梦人生
醉梦人生 2021-02-13 17:03

As is done in the iPhone Mail app, I would like have the \"Delete\" button which appears on swiping an editable table cell from right to left to animate when it is dism

相关标签:
3条回答
  • 2021-02-13 17:43

    I had the same problem, just now found out that there is some problem when we have empty cell.textLabel.text. Try add in

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath:
    {
        {...} // omitted code
        cell.textLabel.text = @"whatever";          
        cell.textLabel.hidden = YES;
    }
    

    With this swipe button dismiss proper, but WHY? PS: tested with custom cells and built i.n

    0 讨论(0)
  • 2021-02-13 17:45

    I've just ran into this issue as well. I have a series of tableViews and I noticed that some of them have the proper dismissal fade and others don't.

    It seems the difference is a UITableViewCellAccessory. If this is set to anything other than UITableViewCellAccessoryNone then you get the proper animation. I think this might be a bug. Can anyone else confirm this behavior?

    0 讨论(0)
  • 2021-02-13 17:51

    You should not need to animate the dismissal manually, it works the same way as invoking it so not sure why it is behaving differently in your app.

    Are you using custom cells by any chance? As a thought for you to try, change the shouldIndentWhileEditingRowAtIndexPath: method to return NO and see if it changes anything. The only thing I can think of is that your content indentation is interfering with the delete button area in a way that the animation can't be performed or is not behaving as it should.

    - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { return NO; }

    0 讨论(0)
提交回复
热议问题