Dare2Dream
Dare2Dream

Reputation: 474

FInd the width of contenView in a UITableViewCell in case of iPad

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

Answers (2)

Muhammad Hewedy
Muhammad Hewedy

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

Dare2Dream
Dare2Dream

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

Related Questions