Automatically determining the size of a UITableViewCell

Posted by hanno on Stack Overflow See other posts from Stack Overflow or by hanno
Published on 2010-04-04T22:02:49Z Indexed on 2010/04/04 22:03 UTC
Read the original article Hit count: 273

Filed under:
|
|

I am trying to determine the size of a UITableCellView. The reason being that I am using one class for different orientations and devices.

The cell contains one subview that is supposed to fill the entire cell. Right know I'm doing this in the UITableViewCell's init method:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
     //iPad
     subv = [[OrbitView alloc] initWithFrame:CGRectMake(52, 5, 660, 420) ];
}else{
     //iPhone
     subv = [[OrbitView alloc] initWithFrame:CGRectMake(15, 5, 290, 200) ];
}

Clearly, there must be a better way of doing this, without the magic numbers. How/Where should I set the frame of the subview in the UITableViewCell so that it fills the entire UITableViewCell?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about objective-c