LoginSignup
6
6

More than 5 years have passed since last update.

UITableViewの見えない所にinsertした時に、表示部分がアニメーションしないようにする

Posted at

UITableViewの見えない所にinsertした時に、それが現在の表示部分より上だと、
グイッと下にずれちゃうのをなんとかする方法です。

答えだけ書くと、

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
  return 40
}

で出来ます。

少し詳しく

estimatedHeightForRowAtを実装すると、中の数値に関係なく何故かアニメーションしなくなります。
UITableViewAutomaticDimensionでもOK。

これが仕様なのかバグなのか、
バグだとして、グイッと下にアニメーションするのがバグなのか、しないのがバグなのか。

公式には何も書いていないので謎です。

絶対に自分の意図通りに動いてほしいなら、contentOffsetとかいじって頑張ると良いと思います。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6