Wednesday, 14 August 2013

iOS - UITableViewCell subviews on rotation

iOS - UITableViewCell subviews on rotation

I have a UITableViewCell subclass with the init method:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString
*)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setBackgroundColor:[UIColor whiteColor]];
[self.contentView setBackgroundColor:[UIColor whiteColor]];
CGFloat xOffset = 10.0;
CGFloat lineWidth = 1.0;
UIView *footerLine = [[UIView alloc]
initWithFrame:CGRectMake(xOffset,
self.frame.size.height
-
lineWidth,
self.frame.size.width
-
xOffset,
lineWidth)];
[footerLine setBackgroundColor:[UIColor redColor]];
[footerLine setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleTopMargin];
[self addSubview:footerLine];
}
return self;
}
So, I'm trying to draw a line at the bottom of the cell (offset a little
in the x direcetion). This draws well upon the table loading, but I loose
the footerLine view when I rotate the device to landscape and then back
again.
I have a feeling this has something to do with the line:
[footerLine setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleTopMargin];
but I've messed around with multiple combinations of the
UIViewAutoresizing enums, and I can't get it to reappear after a rotation.
Is there something I could be missing with the UIViewAutoresizing??

No comments:

Post a Comment