【问题标题】:Control the speed of uitableview insertRowsAtIndexPath animations控制 uitableview insertRowsAtIndexPath 动画的速度
【发布时间】:2012-03-27 09:55:11
【问题描述】:

我使用了 insertRowsAtIndexPath 而不是 reloadData。 第一次加载时,动画太快了,因为行数太多了。

insertRowsAtIndexPath 的动画速度可以控制吗?

谢谢。

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    我认为无法控制动画速度。

    也许您可以改用scrollToRowAtIndesPath

    【讨论】:

      【解决方案2】:

      覆盖 insertRowsAtIndexPaths 并添加您喜欢的自定义动画延迟。

      - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:   (UITableViewRowAnimation)animation
      
       {
      
      for (NSIndexPath *indexPath in indexPaths)
      {
          UITableViewCell *cell = [self cellForRowAtIndexPath:indexPath];
      
          [cell setFrame:CGRectMake(320, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
      
          [UIView beginAnimations:NULL context:nil];
          [UIView setAnimationDuration:1];
          [cell setFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
          [UIView commitAnimations];
      }
      }
      

      【讨论】:

        【解决方案3】:

        绝对未经测试,但您可以尝试 5 秒动画:

        [UIView animateWithDuration:5. animations:^(void){
            [_tableView insertRowsAtIndexPath:... animated:NO];
        }];
        

        【讨论】:

          猜你喜欢
          • 2019-02-14
          • 1970-01-01
          • 2013-08-13
          • 1970-01-01
          • 1970-01-01
          • 2015-03-14
          • 2017-10-23
          • 2015-03-31
          • 1970-01-01
          相关资源
          最近更新 更多