Ios6 在设置表格移动动画后重新绘制表格

Ios6 在设置表格移动动画后重新绘制表格,ios6,uitableview,Ios6,Uitableview,我有一个应用程序,当用户点击表格视图单元格中的按钮时,它会更改该单元格的内容。如果单元格在屏幕底部部分可见,我有一个动画将表格视图向上移动以显示整个单元格,然后在完成后将其向后移动。在iOS 7上,一切正常。但在iOS 6上,移位的单元格只包含移位前可见的内容;选项卡栏后面“隐藏”的任何内容都是白色的。我已尝试调用[self.view setNeedsDisplay],甚至[self.view performSelector:@selectorsetneedsDisplaywithobject:

我有一个应用程序,当用户点击表格视图单元格中的按钮时,它会更改该单元格的内容。如果单元格在屏幕底部部分可见,我有一个动画将表格视图向上移动以显示整个单元格,然后在完成后将其向后移动。在iOS 7上,一切正常。但在iOS 6上,移位的单元格只包含移位前可见的内容;选项卡栏后面“隐藏”的任何内容都是白色的。我已尝试调用[self.view setNeedsDisplay],甚至[self.view performSelector:@selectorsetneedsDisplaywithobject:nil afterDelay:0.5],但仍无法正确重画

我覆盖了table view cell类中的-drawRect:调用[super-drawRect:rect]并在那里设置一个断点,该断点在动画发生之前运行

如何在动画之后进行重画

在自定义UITableViewController中:


我发现了这个问题:

通过这样的动画移动视图不会显示更多数据。剪切可见数据的线相对于单元位于相同的位置,单元相对于视图位于相同的位置。在iOS 7上,它在半透明的选项卡栏后面绘制表格视图,数据已经在那里,但被遮挡了,因此当它移动时,它会显示数据。在iOS 6中,选项卡栏不是半透明的,因此表视图停止在选项卡栏的上边缘。动画移动视图时,会向上移动剪裁视图

解决方案是滚动表格视图,而不仅仅是移动视图:

    CGRect cellRect = [self.tableView convertRect: cell.frame toView: self.tableView.superview];
    CGRect tableRect = self.tableView.frame;
    if (cellRect.origin.y < tableRect.origin.y)
    {
        [self.tableView scrollToRowAtIndexPath: cell.indexPath
                              atScrollPosition: UITableViewScrollPositionTop animated: YES];
    }
    else if (cellRect.origin.y + cellRect.size.height >
             tableRect.origin.y + tableRect.size.height)
    {
        [self.tableView scrollToRowAtIndexPath: cell.indexPath
                              atScrollPosition: UITableViewScrollPositionBottom animated: YES];
    }
    CGRect cellRect = [self.tableView convertRect: cell.frame toView: self.tableView.superview];
    CGRect tableRect = self.tableView.frame;
    if (cellRect.origin.y < tableRect.origin.y)
    {
        [self.tableView scrollToRowAtIndexPath: cell.indexPath
                              atScrollPosition: UITableViewScrollPositionTop animated: YES];
    }
    else if (cellRect.origin.y + cellRect.size.height >
             tableRect.origin.y + tableRect.size.height)
    {
        [self.tableView scrollToRowAtIndexPath: cell.indexPath
                              atScrollPosition: UITableViewScrollPositionBottom animated: YES];
    }