2012-10-30 55 views
0

我正在使用下面的代碼爲響應鍵盤出現/消失而對UITableView高度變化進行動畫處理。Animate UITableView高度變化

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.25]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
CGRect tableFrame = self.messagesTableView.frame; 

if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) { 
    tableFrame.size.height -= kKeyboardHeightPortrait; 
} else { 
    tableFrame.size.height -= kKeyboardHeightLandscape; 
} 

self.messagesTableView.frame = tableFrame; 
[UIView commitAnimations]; 

它的工作如預期,除了一兩件事,只要動畫開始,在表視圖的上半部分的細胞消失。

動畫開始之前: enter image description here

動畫開始後: enter image description here

另外值得一提的是,表視圖是UIBubbleTableView

回答

-1

一個實例那是因爲你從來沒有初始化這些細胞。

+0

單元格已被初始化並添加到屏幕(第一張圖片中的表格視圖的上半部分)。 –

+0

也許調用某種重新加載void? – Barakados

0

我試圖重現您的問題,但不能。無論如何,我剛剛提交了UIBubbleTableView的擴展示例到github中,它做了你正在嘗試做的事情,並且一切看起來都很好,請看看最新的提交(https://github.com/AlexBarinov/UIBubbleTableView/commit/bc0dc5b151241c4ae476c894e23800156e9709a8)

如果您仍然有任何問題,請隨時向github跟蹤器添加問題,或與我聯繫以提供您認爲不適用於調查的源代碼。電子郵件在github配置文件中可用。

+0

原來問題的原因是在動畫塊之後調用scrollToRowAtIndexPath。不管怎麼說,還是要謝謝你。 –