Reputation: 474
On iPAD when you create new UITableViewCell the contentView width set for 320. Is there a way to get the right width? I can't use the width of the current view as the table cells do not span the entire width of the view. Any help would be greatly appreciated.
Upvotes: 7
Views: 3834
Reputation: 30056
I've solved this issue using:
cell.contentView.frame = CGRectMake(cell.contentView.frame.origin.x,
cell.contentView.frame.origin.y,
self.tableView.frame.size.width,
cell.contentView.frame.size.height);
Upvotes: 5
Reputation: 474
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat viewWidth = self.contentView.frame.size.width;
This gives the right width for contentView
. If [super layoutSubviews]
is not called initially then the contentView
frame is not set correctly.
Upvotes: 3