繁体   English   中英

在位置UITableView处插入一行

[英]Insert a row at position UITableView

我有一个表格视图,要在其中插入新行。 我已经这样做了,但是却给出了意外的输出。 我在这里做错什么吗?

 NSIndexPath *indexpath =  [NSIndexPath indexPathForRow:position inSection:0];

NSArray *temp_array = [[NSArray alloc] initWithObjects:indexpath, nil];

[self.table insertRowsAtIndexPaths:temp_array withRowAnimation:UITableViewRowAnimationBottom];

除此以外,我还需要做更多的事情吗? 我正在一个单独的函数中执行此操作(insert_at_position :)感谢您的帮助。

尝试这个

[self.table beginUpdates];
[self.table insertRowsAtIndexPaths:temp_array withRowAnimation:UITableViewRowAnimationBottom];
[self.table endUpdates];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM