gpt4 book ai didi

iphone - 在 UITableView 位置插入一行

转载 作者:行者123 更新时间:2023-11-29 04:27:19 24 4
gpt4 key购买 nike

我有一个 TableView ,我想在其中的某个位置插入新行。我已经这样做了,但它给出了意想不到的输出。我在这里做错了什么吗?

 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];

关于iphone - 在 UITableView 位置插入一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12152799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com