【问题标题】:Move uitableview cell to the top with animation使用动画将uitableview单元格移动到顶部
【发布时间】:2014-03-11 14:56:15
【问题描述】:

简单点,我是新手!

所以我有一个 uitableview,每个单元格中的内容都可以通过网络服务进行更改。

我需要以视觉方式显示任何单元格中发生变化的情况。因此,当单元格的内容发生变化时,我想将特定单元格移动到顶部...使用动画!

这可能吗?怎么做?

【问题讨论】:

    标签: ios objective-c uitableview xcode5


    【解决方案1】:

    之前选择的答案可能是正确的,但从 iOS 5 开始,您可以这样做:

    [tableView moveRowAtIndexPath:indexPathOfRowToMove toIndexPath:indexPathOfTopRow];
    

    【讨论】:

      【解决方案2】:

      无法以编程方式移动行。

      但是,您可以同时插入和删除一行来模拟移动。

      [tableView beginUpdates];
      [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:rowToMove]
                       withRowAnimation:UITableViewRowAnimationLeft];
      [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToMoveTo]
                       withRowAnimation:UITableViewRowAnimationLeft];
      // update your dataSource as well.
      [tableView endUpdates];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-22
        • 1970-01-01
        • 2016-09-28
        • 1970-01-01
        • 1970-01-01
        • 2015-07-18
        • 1970-01-01
        相关资源
        最近更新 更多