3
我有一個UITableView
並想要爲將再次出現的行設置動畫。我也想在動畫之間切換,有些單元應該得到UITableViewRowAnimationLeft
和其他的UITableViewRowAnimationRight
。但我不知道如何使用我的UITableViewController
來實現此功能。我試過的代碼下面幾行插入cellForRowAtIndexPath
:滾動時在UITableViewCells中滑動
[self.tableView beginUpdates];
NSArray *updatePath = [NSArray arrayWithObject:indexPath];
[self.tableView reloadRowsAtIndexPaths:updatePath
withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
在小區滑動相反的,在小區的順序變化或它們中的一些出現了兩次。我也嘗試在創建單元格後插入這些行。
if (cell == nil) {
...
} else {
[self.tableView beginUpdates];
NSArray *updatePath = [NSArray arrayWithObject:indexPath];
[self.tableView reloadRowsAtIndexPaths:updatePath
withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
Thx提前。我會嘗試你的解決方案。當初始化第一行時,我認爲實現此功能並不壞。但是如果我這樣做,它會在初始加載時出現問題嗎? –
這隻取決於你希望它看起來如何。 –
這是一個聊天,行(帶有消息)應該從左側或右側進行動畫,具體取決於誰寫的消息。 –