簡體   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