插入行而不重新加载表

use*_*740 9 iphone objective-c uitableview ios

您好,我有tableview,其中包含许多对象.如果我想在其中添加一行而不重新加载整个表.因为细胞中有一些过程.有人可以帮忙吗?

Sri*_*aju 13

你可以用两种方式做到 -

[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)

要么

[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone];
Run Code Online (Sandbox Code Playgroud)

这里newResults是一个NSArrayNSIndexPath,你需要创建.然后在这些行中插入新行(带有一些动画或没有动画).