一個(gè)定時(shí)器NSTimer 定時(shí)執(zhí)行下面的代碼
self.cellIndex=0;
self.timer= [NSTimerscheduledTimerWithTimeInterval:timeAftertarget:selfselector:@selector(addCell)userInfo:nilrepeats:YES];
#pragma mark ---動(dòng)態(tài)添加cell---
- (void)addCell{
[self.dataArrayaddObject:self.dataArray1[self.cellIndex]];
NSIndexPath*indexPath = [NSIndexPathindexPathForRow:self.cellIndexinSection:0];
//插入
[self.tableViewinsertRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationFade];
//滾動(dòng)
[self.tableViewscrollToRowAtIndexPath:[NSIndexPathindexPathForRow:self.cellIndex
inSection:0]
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
self.cellIndex++;
}