[英]Move uitableview cell to the top with animation
簡單,我是新手!
所以我有一個uitableview,其中包含可以從Web服務更改的每個單元格中的內容。
我需要在視覺上顯示任何單元格中的某些內容發生變化。 因此,我希望在該單元格的內容發生變化時將特定單元格移動到頂部...動畫!
這可能嗎?? 怎么做呢?
無法以編程方式移動行。
但是,您可以同時插入和刪除行以模擬移動。
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:rowToMove]
withRowAnimation:UITableViewRowAnimationLeft];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToMoveTo]
withRowAnimation:UITableViewRowAnimationLeft];
// update your dataSource as well.
[tableView endUpdates];
之前選擇的答案可能是正確的,但是從iOS 5開始,您可以這樣做:
[tableView moveRowAtIndexPath:indexPathOfRowToMove toIndexPath:indexPathOfTopRow];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.