1

データがリロードされた直後に、テーブルビューのコンテンツをアニメーション化しようとしています。私はこれを行うことで成功します:

[_tableView reloadData];
[_tableView setContentInset:UIEdgeInsetsMake(-_tableView.contentSize.height, 0, 0, 0)];
[UIView animateWithDuration:kAnimationDuration animations:^{
    [_tableView setContentInset:UIEdgeInsetsMake(35, 0, 0, 0)];
    [_tableView setContentOffset:CGPointMake(0.0f,-35.f)];
}];

しかし、私のアニメーションは、異なるコンテンツ サイズ (遅いまたは速い) で同じ速度ではありません。速度を調整し、各リロード後にまったく同じアニメーションを表示するにはどうすればよいですか?

4

1 に答える 1

2

テーブル ビューのコンテンツ サイズに比例してアニメーションの長さを設定します。

[_tableView reloadData];
[_tableView setContentInset:UIEdgeInsetsMake(-_tableView.contentSize.height, 0, 0, 0)];

animationDuration = _tableView.contentSize.height * aConstantK;

[UIView animateWithDuration:animationDuration animations:^{
    [_tableView setContentInset:UIEdgeInsetsMake(35, 0, 0, 0)];
    [_tableView setContentOffset:CGPointMake(0.0f,-35.f)];
}];
于 2013-09-20T07:00:49.270 に答える