在iPhone上自动旋转自定义绘制视图

在iPhone上自动旋转自定义绘制视图,iphone,Iphone,我有一个充满自定义绘图单元的UITableView。当视图旋转时,它只是拉伸我的所有自定义图形。当视图旋转时,如何让视图重新绘制自身?我的解决方案是覆盖像WillAnimateRotationInterfaceOrientation:duration:这样: - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)

我有一个充满自定义绘图单元的UITableView。当视图旋转时,它只是拉伸我的所有自定义图形。当视图旋转时,如何让视图重新绘制自身?

我的解决方案是覆盖像WillAnimateRotationInterfaceOrientation:duration:这样:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
}

当然,这只适用于3.0,如果有多个分区,则需要重新加载所有分区。

将视图的
contentMode
设置为
UIViewContentModeRedraw