如何动态地将行添加到特定的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
你能帮我吗?
最好的问候你所有
推荐答案
您可以使用 insertRowsAtIndexPaths:
<$ c $的方法c> 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屋!
查看全文