当一个人在删除一行或添加一行时使用 UITableViewRowAnimation
时,有时如果该行位于 TableView 的极端,则表会滚动。
然而,即使它滚动,它似乎也没有在委托(delegate)上调用 scrollViewDidScroll:
。
例如,我的委托(delegate)中有以下代码。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"Scrolling %f", scrollView.contentOffset.y);
}
如果用户滚动,它会被调用。 但是当我删除一行时:
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
scrollViewDidScroll:
方法根本没有被调用。
有什么方法可以确保在 UITableView
动画时调用它?
谢谢!
最佳答案
如果您不知道,scrollViewDidScroll
仅在响应用户 与 ScrollView (或在本例中为 TableView )的交互时被调用。由于动画而不会响应滚动而调用它。此行为是固定的。你需要找到另一种方法来实现你所追求的目标。也许这个现有的问题可能有用:
How to make UIScrollView send scrollViewDidScroll messages during animations
关于ios - scrollViewDidScroll : on UITableViewRowAnimation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22648168/