Cell animation stop fraction must be greater than start fraction

前端 未结 10 1411
梦毁少年i
梦毁少年i 2020-12-24 06:12

I m using Animation in table view cell...Animation is working fine when cell is totally visible.if any cell is partially visible at that time due to Animation my app is gett

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 06:54

    I solved this bug by calling reloadData() for last section:

    func expandSectionPressed(sender: UIButton) {
        let object = items[sender.tag]
        object.expanded = !object.expanded
        sender.selected = object.expanded
        var indexPaths = [NSIndexPath]()
        for i in 0..<7 {
            indexPaths.append(NSIndexPath(forRow: i, inSection: sender.tag))
        }
        if object.expanded {
            tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .Fade)
        } else {
            // strange crash when deleting rows from the last section //
            if sender.tag < numberOfSectionsInTableView(tableView) - 1 {
                tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: .Fade)
            } else {
                tableView.reloadData()
            }
        }
    }
    

提交回复
热议问题