I have a problem with rowHeight, which seems to be not changed ( though I do it in method heightForRow…)
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0 && indexPath.row == 0) {
return 80;
} else
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[cell setSelectionStyle:UITableViewCellSeparatorStyleNone];
// Configure the cell...
if(indexPath.section == 0 && indexPath.row == 0) {
NSLog(@"frame.size.height: %f rowHeight: %f", cell.frame.size.height, tableView.rowHeight);
}
return cell;
}
It says 44.0000 for both values: cell.frame.size.height and for rowHeight.
Here’s how do I initialize this table in navcontroller:
DPSettingsInformations *settingsInformations = [[DPSettingsInformations alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:settingsInformations animated:YES];
44 is the default height so it sounds as if you haven’t set the
UITableViewDelegate.tableView:heightForRowAtIndexPath:requires theUITableViewDelegateto be set. Make sure that this is set correctly in the Nib, Storyboard or in code. Usually you set it at the same time as theUITableViewDataSource.Example (if setting in code):