Expanding table view cells disappearing

前端 未结 7 1663
傲寒
傲寒 2021-02-12 23:52

I have cells that expand by changing their height with a setExpanded: method call.

I then call reloadRowsAtIndexPaths: to refresh the cells.

The problem is the c

7条回答
  •  迷失自我
    2021-02-13 00:26

    I don't see any difference in behavior between iOS 5.0 and 4.3.2 in the simulator, or 5.0 on my phone—the cells disappear in the same way on each. (I'd test on 4.2.1 on my older iPod touch but Xcode 4 can't. Grr..) It looks like there's an easy workaround, though: If you do both reloadRowsAtIndexPaths:withRowAnimation: after expanding/collapsing your cells and then the reloadData call after that, it appears to preserve the animation.

    Here's a small demo project for this. It's hard to say what the actual problem was—it's just some odd side effect of how UIKit is doing the cell animation. If you subclass [UITableViewCell setAlpha:] you can see that the table view is setting the cell's alpha to 0 and leaving it there. Weird.

    Edit: Well that's weird. It wasn't working for a bit (was doing the old behavior, with cells disappearing), but now it's right again. Maybe I was running the wrong version. Anyway, let me know if this works for you.

提交回复
热议问题