我有一個應用程序,當用戶點擊該單元格中的按鈕時,可以更改表格視圖單元格的內容。如果單元格在屏幕底部部分可見,則我有一個動畫將表格視圖向上移動以顯示整個單元格(然後在完成時將其移回)。在iOS 7上,一切都很好。但是在iOS 6上,移位後的單元只包含在移位前可見的內容;標籤欄後面隱藏的任何內容都是空白的。我試過撥打[self.view setNeedsDisplay]
,甚至[self.view performSelector: @selector(setNeedsDisplay) withObject: nil afterDelay: 0.5]
,但它仍然沒有正確重畫。動畫移動後重繪表格
我在表視圖單元格類中覆蓋了-drawRect:
,調用[super drawRect: rect]
並在那裏設置斷點,並在動畫發生之前運行。
如何在動畫之後重繪動畫?
在定製UITableViewController
:
- (void) shiftTable: (CGFloat) distance
{
[UIView beginAnimations: @"TableShift" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: 0.35];
self.view.frame = CGRectOffset(self.view.frame, 0, distance);
[UIView commitAnimations];
}