[英]move an UITableViewCell with animation between 2 sections in a UITableView
在一個應用程序中,UITableView中有2個部分。 我希望將帶有動畫的UITableViewCell從UITableView的一個部分移動到另一部分,這可能嗎?
歡迎任何評論
謝謝
UITableView
有答案:
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
因此,從第一行中刪除該條目並將其添加到第二行。 您可以選擇多種動畫。
作為一個示例(抱歉,沒有編譯器就從內存中執行此操作)。 假設:section0Data保存您的第一部分的數據,section1Data保存您的第二部分的數據。
[self.section0Data removeObjectAtIndex:removeIdx];
[self.section1Data insertObject:entry atIndex:insertIdx];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:removeIdx inSection:0]]
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:insertIdx inSection:1]]
withRowAnimation:UITableViewRowAnimationFade];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.