如何将行动态添加到特定的 UITableView 部分? [英] How to dynamically add rows to a specific UITableView section?
本文介绍了如何将行动态添加到特定的 UITableView 部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一名新的 IOS 程序员,我遇到了一个问题.
I am a new IOS Programmer, and i am having a issue.
我有一个包含 2 个部分的 UITableView,一个是静态的,另一个是动态的.
I have a UITableView with 2 sections, one then is static, and another one is dynamical.
在特定操作中,我需要在运行时为第二部分添加新行..
In specific actions i need to add new rows for the second section in runtime..
我知道如何管理 UITableView ,但不知道如何管理特定部分
I know how to manage a UITableView , but not a specific section
你能帮我吗?
向大家致以诚挚的问候
推荐答案
可以使用UITableView
//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];
这篇关于如何将行动态添加到特定的 UITableView 部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文