The table resizes its width after changing between portrait and landscape mode. The table view is grouped. I need to calculate wid开发者_StackOverflowth of contentView to change width of a progress indicator. I'm trying
float contentWidth = [tableView cellForRowAtIndexPath:indexPath].contentView.frame.size.width;
But jus after rotation it gives an old value which changes after scrolling.
Try this
float contentWidth = [tableView cellForRowAtIndexPath:indexPath].contentView.bounds.size.width;
Or you can just set appropriate autoresizingMask
for your progress indicator when configuring it:
progressIndicator.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
You can reload the tableView after the rotation has finished using the method below:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self.tableView reloadData];
}
This should give you the newer value.
精彩评论