Objective c UITableView分组-如何获取单元格宽度';旋转后的内容视图

Objective c UITableView分组-如何获取单元格宽度';旋转后的内容视图,objective-c,ipad,uitableview,Objective C,Ipad,Uitableview,在纵向和横向模式之间切换后,表格将调整其宽度。表视图已分组。我需要计算contentView的宽度来更改进度指示器的宽度。 我正在努力 float contentWidth = [tableView cellForRowAtIndexPath:indexPath].contentView.frame.size.width; 但旋转后,它会给出一个旧值,在滚动后会发生变化。试试这个 float contentWidth = [tableView cellForRowAtIndexPath:ind

在纵向和横向模式之间切换后,表格将调整其宽度。表视图已分组。我需要计算contentView的宽度来更改进度指示器的宽度。 我正在努力

float contentWidth = [tableView cellForRowAtIndexPath:indexPath].contentView.frame.size.width;
但旋转后,它会给出一个旧值,在滚动后会发生变化。

试试这个

float contentWidth = [tableView cellForRowAtIndexPath:indexPath].contentView.bounds.size.width;
或者,您也可以在配置进度指示器时为其设置适当的
自动重新设置任务

progressIndicator.autoresizingMask = UIViewAutoresizingFlexibleWidth |  UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

旋转完成后,可以使用以下方法重新加载tableView:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

    [self.tableView reloadData];

}

这将为您提供较新的值。

谢谢,我一到我的计算机就试试这个。但我注意到,当加载表视图时,内容视图的宽度小于分组单元格的可见宽度。也许是因为它是从nib加载的。谢谢,我忘记了边界,我也会检查这个方法。