简体   繁体   中英

iOS 7.1 insertRowsAtIndexPaths animation doesn't work

I'm testing my app on iOS 7.1 and when the following line is executed, the cells disappear for a short period (about a second) and then the new cell with old ones appear without any animation.

[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationBottom];

Same thing happens when I remove a cell with animation.

This problem doesn't exist on iOS7. I have tested on both on simulator and device by the way. What could be the problem?

Edit: I figured out the problem, below you can find the answer.

Well the problem was caused by setting the table cell's background: [UIColor clearColor]; I figured out while debugging. Since my tableview's background is a solid color, I assigned that color to background of my cell view, and now the animation works normally and cells don't disappear anymore. However, I have no idea why this happens in iOS 7.1, and not in iOS 7.0.

It works perfectly)))) You wrote not to use animation: UITableViewRowAnimationNone .
Replace it with UITableViewRowAnimationAutomatic , for example.

Try to use the line (with animation as @nicael suggested) between the lines:

[self.tableView beginUpdates];

...

[self.tableView endUpdates];

Sometimes it makes a difference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM