Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

animation issue with UITableView footer View when performing "beginUpdates" "endUpdates"

When I'm changing a cell height with animation (using beginUpdates(), endUpdates()) I'm having a very weird animation for my section footer : it's moving at the bottom of the tableview.

here is the simplest code i could write

func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
    return "footer"
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return cellHeight
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    return tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    tableView.beginUpdates()
    cellHeight += 20;
    tableView.endUpdates()
}

How could I avoid this animation issue ?

like image 906
Jowann Avatar asked Nov 01 '22 16:11

Jowann


1 Answers

I'm having the exact same problem (the footer moves to the bottom of the tableview and stays there). It looks like it's an iOS8 bug (it doesn't happen on iOS7).

In my case, a workaround is to return the footer as the next section header...

like image 183
Jyaif Avatar answered Nov 11 '22 14:11

Jyaif