2013-05-20 37 views
15

我正在爲我的UITableView進行延遲加載,所以我試圖在圖像更新時重新加載單個行。然而,我遇到了一個奇怪的問題。UITableView reloadSection和reloadRowsAtIndexPaths導致奇怪的動畫

當我打電話,

[self.bubbleTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone]; 

OR

[self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone]; 

當我明確說不動畫仍然動畫和動畫的圖像佔用了整個小區並迅速縮小到正常大小。另外,如果我將其更改爲任何其他動畫,則無論設置如何,它都會執行相同的動畫。

如果我評論其中任何一個,只是使用reloadData它可以正常工作,但我寧願不reloadData重新計算不需要更新的單元的性能原因。

謝謝!

+0

同樣的問題。你解決了嗎? –

回答

36

Here was an answer

[UIView setAnimationsEnabled:NO]; 
[self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone]; 
[UIView setAnimationsEnabled:YES]; 

這對我的作品。

UPD。通過@與塊相同Şafak-基色

[UIView performWithoutAnimation:^{ 
    [self.bubbleTableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone]; 
}]; 

SWIFT

UIView.performWithoutAnimation { 
      self.bubbleTableView.reloadSections(NSIndexSet(index: indexPath.section), withRowAnimation: UITableViewRowAnimation.None) 
     } 
0

使用cellForRowAtIndexPath:只更新細胞,你有興趣。

+0

我沒有更新我感興趣的問題,但我無法更新沒有這個奇怪的動畫的特定單元格。 – Alan

+0

但是,如果您獲取單元格(使用cellForRowAtIndexPath),則可以更新單元格中的圖像。將不會有動畫,因爲你不會調用任何重載*方法。 – Markus

+0

嗯..我正在更新單元格中的圖像,但我遇到的問題是圖像不會更新,直到我reloadData或單元格離開屏幕並重新開始。 – Alan

-1

我發現這事會發生在我的iPhone模擬器。經過幾次重新加載,它沒有動畫正常工作。可能只是模擬器中的一個錯誤。

+1

它也在設備上發生 –

7

以下方法爲我工作:(適用於iOS 7更好)這裏

[UIView performWithoutAnimation:^{ 
    [tableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone]; 
}];