reloadRowsAtIndexPaths:withRowAnimation: crashes my app

后端 未结 8 1978
谎友^
谎友^ 2021-02-07 01:33

I got a strange problem with my UITableView: I use reloadRowsAtIndexPaths:withRowAnimation: to reload some specific rows, but the app crashes with an seemingly unre

8条回答
  •  [愿得一人]
    2021-02-07 02:07

    You should check cell visibility before reload. Here is Swift 3 code:

            let indexPath = IndexPath(row: offset, section: 0)
            let isVisible = tableView.indexPathsForVisibleRows?.contains{$0 == indexPath}
            if let v = isVisible, v == true {
                tableView.reloadRows(at: [indexPath], with: .automatic)
            }
    

提交回复
热议问题