Я загрузки пользовательских ячейки из XIb, в которой высота ячейки составляет 64, а затем с помощью heightForRowAtIndexPath
изменить высоту ячейки, как следующее:заблуждение относительно высоты ячейки, UITableViewCell, IOS
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
UINib *cellNIB = [UINib nibWithNibName:NSStringFromClass([TableCell class]) bundle:nil];
[tableView registerNib:cellNIB forCellReuseIdentifier:NSLocalizedString(@"TableCell", nil)];
[self.view addSubview:tableView];
}
(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 400 ;
}
В cellForRowAtIndex
, я распечатывания высоту ячейки
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:NSLocalizedString(@"TableCell", nil)];
NSLog(@"height at:%ld is %@",(long)indexPath.item,NSStringFromCGRect(cell.frame));
[cell setGradient];
return cell;
}
интересно, что консоль дает мне высоту ячейки 64 (который исходит от XIb)
Предполагается, что это 400?
Любые идеи, почему я получаю 64 вместо 400. Любые комментарии приветствуются здесь. Благодаря
PS:
@implementation TableCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
Не могли бы вы показать код вашего 'UITableViewCell'? –
my TableCell является подклассом UITableViewCell, и я обновил свой пост с его классом реализации (фактически, в файле реализации нет ничего нового) – tranvutuan
Как-то вы можете установить высоту 'UITableViewCell' программно? –