2014-03-10 6 views
1

Я создал подкласс UITableViewCell, который содержит UITextField. Однако, когда я добавляю эту ячейку в свой сгруппированный вид таблицы в iOS 6, ячейка расширяется до краев представления таблицы.iOS 6 пользовательский сгруппированный UITableViewCell неправильный размер

The Name field is extended but the Company and Season fields are in the same tableview yet the correct size

Вот код для пользовательской ячейки.

#import "ActivityNameEditCell.h" 

@implementation ActivityNameEditCell 

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     self.textField = [[UITextField alloc] init]; 

     [self addSubview:self.textField]; 
    } 
    return self; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

- (void)layoutSubviews 
{ 
    self.textField.frame = CGRectMake(self.contentView.frame.origin.x + 10, 0, self.frame.size.width - self.contentView.frame.origin.x - 10, self.frame.size.height); 
} 

@end 

Этот же класс клетка выкладывает правильно прошивкой 7

Есть ли что-нибудь со всей очевидностью, что я сделал не так? Как я могу исправить ячейку в iOS 6?

+0

Я думаю, что '' self.contentView.frame.origin.x' в CGRectMake' вызывает проблему в iOS6 – Akhilrajtr

ответ

2

Я просто забыл позвонить [super layoutSubviews] в моей layoutSubviews реализации. Derp ...

enter image description here

1

причина из-за настроенный макет в вашем файле класс

- (void)layoutSubviews 
{ 
    self.textField.frame = CGRectMake(self.contentView.frame.origin.x + 10, 0, self.frame.size.width - self.contentView.frame.origin.x - 10, self.frame.size.height); 
} 

Здесь self.contentView.frame.... сравнительно отличаются от IOS7.

Проверьте мой ANSWER here для получения дополнительной информации

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