2016-09-05 22 views
0

我收到信息時重新載入了表格。桌子上的動畫不見了

這裏是代碼:

[self.tblChatting beginUpdates]; 
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:app.Glb.arrayChat.count-1 inSection:0]; 
[self.tblChatting insertRowsAtIndexPaths:[indexPaths copy] withRowAnimation:UITableViewRowAnimationBottom]; 
[self.tblChatting endUpdates]; 

[self.tblChatting reloadData]; 
[self.tblChatting scrollToRowAtIndexPath:newIndexPath 
         atScrollPosition:UITableViewScrollPositionBottom 
           animated:YES]; 

,這裏是我的表視圖對象的細節時不是有動畫和我行不添加到表:

<UITableView: 0x18bece00; frame = (0 55; 250 351); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = 
<NSArray: 0x17ec5fb0>; layer = <CALayer: 0x17ec5150>; contentOffset: {0, 6541}; contentSize: {250, 6892.0312}> 

,這裏是表視圖對象當行添加succesfull和animatoin的對象:

<UITableView: 0x14949e00; frame = (0 55; 320 351); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x14665210>; animations = { position=<CASpringAnimation: 0x1a75d9f0>; bounds.origin=<CASpringAnimation: 0x1a4e9d20>; bounds.size=<CASpringAnimation: 0x1ac4b980>; 
bounds.origin-2=<CASpringAnimation: 0x1a1fbb40>; bounds.size-2=<CASpringAnimation: 0x1a1b02d0>; }; 
layer = <CALayer: 0x145f1300>; contentOffset: {0, 6593}; contentSize: {320, 6944.1309}> 

,而且有時只發生。 爲什麼會發生這種情況?

+0

刪除,表重裝。 –

回答

0

刪除線

[self.tblChatting reloadData]; 

insertRowsAtIndexPaths隱式重新排列表格視圖。

也刪除begin/endUpdates行。它們對單個插入操作沒有影響。

0

這一點你插入表格視圖的行以及重新加載表:

試試這個:

NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:app.Glb.arrayChat.count-1 inSection:0]; 

[self.tblChatting insertRowsAtIndexPaths:@[indexPaths] withRowAnimation:UITableViewRowAnimationBottom]; 

[self.tblChatting scrollToRowAtIndexPath:newIndexPath 
         atScrollPosition:UITableViewScrollPositionBottom 
           animated:YES];