简体   繁体   English

具有2个动画的insertRowsAtIndexPaths

[英]insertRowsAtIndexPaths with 2 animations

I am currently inserting cells in my UITableView with the following code: 我目前正在使用以下代码在UITableView插入单元格:

[rottenTableView insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:UITableViewRowAnimationTop];

It does the job correctly with the animation UITableViewRowAnimationTop . 它使用动画UITableViewRowAnimationTop正确完成了工作。 However, I would like to insert the cells with 2 animations at the same time ( UITableViewRowAnimationTop and UITableViewRowAnimationFade ). 但是,我想同时插入具有2个动画的单元格( UITableViewRowAnimationTopUITableViewRowAnimationFade )。 I tried the following: 我尝试了以下方法:

[rottenTableView insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:(UITableViewRowAnimationTop|UITableViewRowAnimationFade)];

This code does not seem to animate insertion any differently than before. 此代码似乎对插入的动画没有任何不同。 Any way to perform both animations? 有办法执行两个动画吗?

As far as I know, when you use -insertRowsAtIndexPaths:withRowAnimation: there could be only one animation type for a single cell simultaneously. 据我所知,当您使用-insertRowsAtIndexPaths:withRowAnimation: ,单个单元格可能同时只有一种动画类型。 But I could suggest using different animation types for different cells at the same time. 但是我建议同时为不同的单元格使用不同的动画类型。 For this you can use batch UITableView cell's updation via using beginUpdates / endUpdates . 为此,您可以通过使用beginUpdates / endUpdates使用批处理UITableView单元的更新。 All the animations will fire at the same time, you can use it like this: 所有动画将同时触发,您可以像这样使用它:

[tableView beginUpdates];

[tableView insertRowsAtIndexPaths:insertIndexPaths1 withRowAnimation:UITableViewRowAnimationRight];
[tableView insertRowsAtIndexPaths:insertIndexPaths2 withRowAnimation:UITableViewRowAnimationOTHER];

[tableView endUpdates];

For details check this: Batch Insertion, Deletion, and Reloading of Rows and Sections . 有关详细信息,请检查以下内容: 批量插入,删除和重新加载行和节
Also check this question about custom insertion animations: Can you do custom animations for UITableView Cell Inserts? 还要检查有关自定义插入动画的以下问题:是否可以为UITableView单元格插入执行自定义动画?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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