How can I tell When a UITableView animation has finished?

前端 未结 3 736
生来不讨喜
生来不讨喜 2020-12-09 17:08

How can I tell when [UITableView setEditing:YES animated:YES] has completed?

I don\'t want to give any context, because I want to avoid anybody giving me workarounds

相关标签:
3条回答
  • 2020-12-09 17:41
    [CATransaction begin];
    [CATransaction setCompletionBlock: ^{
        // your animation has finished
    }];
    [tableView setEditing:YES animated:YES];
    [CATransaction commit];
    

    Note that setCompletionBlock must be on the top.

    0 讨论(0)
  • 2020-12-09 17:43

    Swift 4 version of accepted answer:

    CATransaction.begin()
    CATransaction.setCompletionBlock {
        // your animation has finished
    }
    tableView.setEditing(true, animated: true)
    CATransaction.commit()
    
    0 讨论(0)
  • 2020-12-09 17:57

    In iOS 4 you can do the following:

    [UIView animateWithDuration:0.3f
                     animations:^{
                         [self.tableView setEditing:YES animated:NO];
                     } 
                     completion:^(BOOL finished){
                         // Do something
                     }
    ];
    
    0 讨论(0)
提交回复
热议问题