开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜