iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – reloadSections的麻烦:withRowAnimation动画大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我有一个UITableView有两个部分(顶部和底部).当在顶部(第0部分)“检查”项目时,我将它们移动到底部(第1部分),反之亦然.除了动画,一切都很好. 我正在使用以下内容,但行动作缓慢 – 我在其他应用程序中看到了更好的结果.我希望从顶部开始的行能够干净地动画到底部…以及从底部开始的行,以便在选中或取消选中它们时干净地动画到顶部. // set the guests arrival stat
我有一个UITableView有两个部分(顶部和底部).当在顶部(第0部分)“检查”项目时,我将它们移动到底部(第1部分),反之亦然.除了动画,一切都很好.

我正在使用以下内容,但行动作缓慢 – 我在其他应用程序中看到了更好的结果.我希望从顶部开始的行能够干净地动画到底部…以及从底部开始的行,以便在选中或取消选中它们时干净地动画到顶部.

// set the guests arrival status and use animation
    [guestList beginupdates];
    if (!guest.didArrivE) {
        [guest setDidArrive:YES];
        [guestList reloadSections:sectionIndexSet withRowAnimation:UITableViewRowAnimationBottom];
    } else {
        [guest setDidArrive:NO];
        [guestList reloadSections:sectionIndexSet withRowAnimation:UITableViewRowAnimationTop];
    }
    [guestList endupdates];

[guestList reloadData];

我该怎么编码才能获得流畅的动画?

编辑:

发现了这个问题.可能应该这样编写:

//NSIndexSet *sectionIndexSet = [NSIndexSet indexSetWithIndexesInRange:NsmakeRange(0,1)];

    // set the guests arrival status and use animation
    [guestList beginupdates];
    if (!guest.didArrivE) {
        [guest setDidArrive:YES];
        [guestList reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationBottom];
    } else {
        [guest setDidArrive:NO];
        [guestList reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationTop];
    }
    [guestList endupdates];
[guestList reloadData];

注意我注释掉的第一行.我原本忽略了这个.如您所见,我使用的是构造不良的NSIndexSet.

解决方法

问题解决了.请参阅已编辑的回复.代码应该是:

// set the guests arrival status and use animation
[guestList beginupdates];
if (!guest.didArrivE) {
    [guest setDidArrive:YES];
    [guestList reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationBottom];
} else {
    [guest setDidArrive:NO];
    [guestList reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationTop];
}
[guestList endupdates];
[guestList reloadData];

大佬总结

以上是大佬教程为你收集整理的ios – reloadSections的麻烦:withRowAnimation动画全部内容,希望文章能够帮你解决ios – reloadSections的麻烦:withRowAnimation动画所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。