2013-08-14 2 views
1

У меня есть 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 ??

+0

Вы можете попробовать добавить свой '' footerLine на 'self.contentView'. – liuyaodong

ответ

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 


} 
+0

Как ни странно, это работает! Благодаря! – Brett

Смежные вопросы