views:

257

answers:

1

I've subclassed UITableViewCell and incorporated some subviews via the layoutSubviews method. All views are allocated and initiated in the initWithStyle method, and frames are set in the layoutSubviews method, like so:

initWithStyle:... {
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectZero];
myLabel.someProperties = Configured;
[self.contentView addSubview:myLabel];

layoutSubviews {
CGRect labelRect = CGRectMake(10.0f, 5.0f, 35.0f, 180.0f);
myLabel.frame = labelRect;

Setting the shouldAutoRotateOrientation to YES in the viewController rotates the NavigationController, tableView and UIToolbar appropriately, but the contents of the tableViewCells don't move. I'm not clear on where or what to add as far as AutoResizingMasks. The combinations I've tried so far haven't done anything. Can someone give me a hand?

Thanks!

A: 

The answer I've come up with is to use conditional coding to place view frames, dependent on orientation, in the layoutSubviews method

-(void)layoutSubviews {
    //For portrait mode (NOT PORTRAIT UPSIDE DOWN)
    if ( UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation]) ) {
        CGRect portraitFrame = CGRectMake(Portrait Frame Coordinates);
        myLabel.frame = portraitFrame;
    } else {
    //For landscape modes
        CGRect landscapeFrame = CGRectMake(landscape frame coordinates);
        myLabel.frame = landscapeFrame;
    }
}

Seems hacked together but it works in subclassed UITableViewCells

JustinXXVII