我是一名新的 IOS 程序员,我遇到了一个问题。
我有一个包含 2 个部分的 UITableView,一个是静态的,另一个是动态的。
在特定操作中,我需要在运行时为第二部分添加新行..
我知道如何管理 UITableView ,但不知 Prop 体的部分
你能帮帮我吗?
祝大家好运
最佳答案
您可以使用 UITableView
的 insertRowsAtIndexPaths:
方法
//Update data source with the object that you need to add
[tableDataSource addObject:newObject];
NSInteger row = //specify a row where you need to add new row
NSInteger section = //specify the section where the new row to be added,
//section = 1 here since you need to add row at second section
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationRight];
[self.tableView endUpdates];
关于ios - 如何动态地将行添加到特定的 UITableView 部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23821088/