У меня есть UITableViewCell
подкласса с помощью метода инициализации:IOS - 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;
}
Итак, я пытаюсь нарисовать линию в нижней части ячейки (смещение немного в й direcetion). Это хорошо подходит для загрузки таблицы, но я теряю представление footerLine, когда поворачиваю устройство на пейзаж, а затем обратно.
У меня есть ощущение, что это имеет какое-то отношение к линии:
[footerLine setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
, но я возился с несколькими комбинациями UIViewAutoresizing
перечислений, и я не могу получить его снова после поворота ,
Есть ли что-то, что я мог бы потерять с помощью UIViewAutoresizing
??
Вы можете попробовать добавить свой '' footerLine на 'self.contentView'. – liuyaodong