cell延迟显示,效果好像一个一个加…

来源:互联网 发布:js中获取元素的属性值 编辑:程序博客网 时间:2024/06/04 08:55
一个定时器NSTimer 定时执行下面的代码
self.cellIndex=0;

self.timer=[NSTimerscheduledTimerWithTimeInterval:timeAftertarget:selfselector:@selector(addCell)userInfo:nilrepeats:YES];

#pragma mark ---动态添加cell---

- (void)addCell{

[self.dataArrayaddObject:self.dataArray1[self.cellIndex]];

    

    NSIndexPath*indexPath = [NSIndexPathindexPathForRow:self.cellIndexinSection:0];

    //插入

   [self.tableViewinsertRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationFade];

    

    //滚动

   [self.tableViewscrollToRowAtIndexPath:[NSIndexPathindexPathForRow:self.cellIndex

                                     

                                                    inSection:0]

     

                     atScrollPosition:UITableViewScrollPositionTop

     

                             animated:YES];

    

 

   self.cellIndex++;

}

0 0