ios - 如何动态地将行添加到特定的 UITableView 部分?

标签 ios objective-c uitableview

我是一名新的 IOS 程序员,我遇到了一个问题。

我有一个包含 2 个部分的 UITableView,一个是静态的,另一个是动态的。

在特定操作中,我需要在运行时为第二部分添加新行..

我知道如何管理 UITableView ,但不知 Prop 体的部分

你能帮帮我吗?

祝大家好运

最佳答案

您可以使用 UITableViewinsertRowsAtIndexPaths: 方法

//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/

相关文章:

ios - viewForHeaderInSection 对齐错误(Swift 3)

ios - swift 3 iOS:将UInt8数组转换为int8

ios - CloudKit,我的授权不工作

objective-c - 关于 Objective C 中的内存管理

iphone - 我如何为我的 iPhone 应用程序集成谷歌地图 API?

iOS:处理数据和大量 View

ios - 嵌套 ScrollView 与 TableView 或其他满足此要求的 View

ios - 如何使用GADRewardBasedVideoAd

objective-c - 属性访问、风格还是实质内容?

ios - 从 TableView 中删除行 | NSUserDefaults + NSKeyedArchiver