Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 766
Dare2Dream Avatar asked Oct 20 '10 20:10

Dare2Dream


2 Answers

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);
like image 110
Muhammad Hewedy Avatar answered Oct 26 '22 23:10

Muhammad Hewedy


- (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.

like image 35
Dare2Dream Avatar answered Oct 27 '22 01:10

Dare2Dream