我有一个带有init方法的UITableViewCell
子类:
- (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;
}
所以,我试图在单元格的底部画一条线(在x方向偏移一点)。这很好地适用于表格加载,但是当我将设备旋转到横向然后再返回时,我松开了footerLine视图。
我觉得这与这条线有关:
[footerLine setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
但是我已经弄乱了UIViewAutoresizing
枚举的多种组合,我不能让它在轮换后重新出现。
UIViewAutoresizing
??
答案 0 :(得分:3)
我建议你添加cell.m文件
- (void)layoutSubviews{
//there you should define your size for your line
//footer line can be recognized by tag or define in cell it is up to you
}