vendredi 30 janvier 2015

confusing about the height of cell, UITableViewCell,iOS

I am loading a custom cell from xib in which the height of cell is 64 and then using heightForRowAtIndexPath to change the height of cell like following :



- (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 ;
}


At cellForRowAtIndex, I am printing out the height of cell



- (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;
}


It is interesting that the console gives me the height of cell of 64 ( which comes from the xib )


Is it supposed to be 400 ?


Any ideas why I am getting 64 instead of 400. Any comments are welcomed here. Thanks




Aucun commentaire:

Enregistrer un commentaire