开发者

UITableView grouped - how to get width of cell's contentView after rotation

开发者 https://www.devze.com 2023-04-04 00:16 出处:网络
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 in

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消