我在iOS 11的UITableView
中遇到问题。如果我在一个块中重新加载带有UITableViewRowAnimationFade
行动画的表格视图单元格,则会导致表格视图在动画时滚动跳转发生。在警报控制器的警报操作中,它发生在我身上。我该如何防止这种情况发生?这是一个例子。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
// save
[alertController addAction:[UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// this causes a scroll jump when called in this block
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}]];
// cancel
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
}
编辑:这与有问题的副本不同。我的表格视图没有滚动到某个部分的顶部。如果在使用淡入淡出动画重新加载表格视图单元格时从顶部向下滚动,它只是滚动跳跃可能是10个像素。