scrollViewDidScroll:在UITableViewRowAnimation上? [英] scrollViewDidScroll: on UITableViewRowAnimation?

查看:41
本文介绍了scrollViewDidScroll:在UITableViewRowAnimation上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当删除行或添加行时使用 UITableViewRowAnimation 时,有时如果此行位于表视图的最末端,则表会滚动.

When one uses a UITableViewRowAnimation upon deletion of a row or the addition of a row, sometimes if this row is at the extremes of the tableview the table scrolls.

但是,即使它滚动了,它似乎也没有在委托上调用 scrollViewDidScroll:.

Yet, even though it scrolls it doesn't seem to call scrollViewDidScroll: on the delegate.

例如,我的委托人中包含以下代码.

For example, I have the following code in my delegate.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"Scrolling %f", scrollView.contentOffset.y);
}

如果用户滚动,哪个会被呼叫.但是当我删除一行时:

Which gets called if the user scrolls. But when I have a deletion of a row:

[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

根本没有调用 scrollViewDidScroll:方法.

有什么方法可以确保在 UITableView 动画时调用此函数吗?

Is there any way to ensure that this gets called while the UITableView is animating?

谢谢!

推荐答案

您可以改用以下方法.

    [CATransaction setCompletionBlock: ^{
        // do stuff
    }];

    [CATransaction begin];

    [tableView beginUpdates];
    [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
    [tableView endUpdates];

    [CATransaction commit];

这篇关于scrollViewDidScroll:在UITableViewRowAnimation上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆