在 UITableView的底部插入新的cell

来源:互联网 发布:c 网络编程 好书 编辑:程序博客网 时间:2024/06/03 21:21

//添加celltableView

   NSIndexPath * newIndexPath = [NSIndexPathindexPathForRow:self.historyArr.count-1inSection:0];

    [self.chatTableViewbeginUpdates];

    [self.chatTableViewinsertRowsAtIndexPaths:[NSArrayarrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationBottom];

    [self.chatTableViewendUpdates];

    [self.chatTableViewscrollToRowAtIndexPath:newIndexPathatScrollPosition:UITableViewScrollPositionBottomanimated:YES];

   // 添加刷新后使tableView恢复frame

    [self.chatTableViewreloadData];

这部分工作在dispatch_get_main_queue主线程中进行,否则的话在自己的代码中出现刷新不及时,视图层显示以前cell的数据

原创粉丝点击