How to get notified when scrollToRowAtIndexPath finishes animating

前端 未结 6 1863
梦如初夏
梦如初夏 2020-11-30 09:57

This is a follow-up to How to get notified when a tableViewController finishes animating the push onto a nav stack.

In a tableView I want to deselect a

6条回答
  •  庸人自扰
    2020-11-30 10:02

    You can include the scrollToRowAtIndexPath: inside a [UIView animateWithDuration:...] block which will trigger the completion block after all included animations conclude. So, something like this:

    [UIView
        animateWithDuration:0.3f
        delay:0.0f
        options:UIViewAnimationOptionAllowUserInteraction
        animations:^
        {
            // Scroll to row with animation
            [self.tableView scrollToRowAtIndexPath:indexPath
                                atScrollPosition:UITableViewScrollPositionTop
                                        animated:YES];
        }
        completion:^(BOOL finished)
        {
            // Deselect row
            [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
        }];
    

提交回复
热议问题