[英]iOS - UITableViewCell subviews on rotation
I have a UITableViewCell
subclass with the init method: 我有一个带有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;
}
So, I'm trying to draw a line at the bottom of the cell (offset a little in the x direcetion). 所以,我试图在单元格的底部画一条线(在x方向偏移一点)。 This draws well upon the table loading, but I loose the footerLine view when I rotate the device to landscape and then back again. 这很好地适用于表加载,但是当我将设备旋转到横向然后再返回时,我松开了footerLine视图。
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. 但是我已经弄乱了UIViewAutoresizing
枚举的多种组合,我不能让它在旋转后重新出现。
Is there something I could be missing with the UIViewAutoresizing
?? UIViewAutoresizing
有什么我可以遗漏的UIViewAutoresizing
?
I suggested you to add in cell.m file 我建议你添加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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.