2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Swift] Assertion failure in -[UITableView _endCellAnimationsWithContext:] 解決方法

Last updated at Posted at 2016-02-07

目的

セルをスワイプで削除した時に発生したエラー
Assertion failure in -[UITableView _endCellAnimationsWithContext:]を解決する.

解決方法

今回、問題だったのは、tableView(tableView: UITableView, numberOfRowsInSection section: Int)の内部が原因だった。
セクションあたりのセルの個数を別の変数で管理していたため、セルをスワイプで削除した後、再描画される時に、セクションあたりのセルの個数が誤った数値を返していた。
解決方法は単純で、tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)の前にセクションあたりのセルの個数を決める変数の値を一つ下げてやれば上手くいく。

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?