【问题标题】:how to make UITableViewRowAnimation have delay or slower than standart?如何使 UITableView 行动画比标准延迟或慢?
【发布时间】:2011-11-30 09:25:25
【问题描述】:
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath {

    UITableView *tableView = self.tableViewA;
    DLog(@"%@", self.tableViewA);
    switch(type) {
        case NSFetchedResultsChangeInsert:

            DLog(@"MASUK Insert");
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationRight];
            break;

        case NSFetchedResultsChangeDelete:
            DLog(@"MASUK Delete");
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
            break;

        case NSFetchedResultsChangeUpdate:
            DLog(@"MASUK Update");
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationNone];
            //[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
            break;

        case NSFetchedResultsChangeMove:
            DLog(@"MASUK Move");
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationRight];
            break;
    }

使用这段代码,我让 UITableView 在插入等时有动画。但我认为它太快了。我想让它慢慢移动。我可以这样做吗?

【问题讨论】:

    标签: xcode uitableview animation row


    【解决方案1】:

    我认为您必须将对 insertRowsAtIndexPathsdeleteRowsAtIndexPaths 的调用封装在对 beginUpdatesendUpdates 的调用中。不过我不知道控制动画速度的方法。

    编辑:这并不完全正确。我显然不知道我在说什么。不要投票。

    【讨论】:

    • 不清楚。为什么我要包装对 insertRowsAtIndexPaths 和 deleteRowsAtIndexPaths 的调用
    • AFAIK,这就是表格视图知道如何为行添加/减法设置动画。
    • 忽略我。它显然在没有开始/结束更新的情况下为表格设置动画。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多