How to change the height of a grouped tableViewCell?

I am trying to display the address displayed in the Contact application for iPhone. therefore it seems that I need a cell three times the height of a normal cell. since it will always be the same, I just need to apply a fixed height to the code. but I don’t know how to do it. my current code

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *address = [NSString stringWithFormat:@"%@\n"@"%@ %@ %@\n"@"%@", dispAddress, dispCity, dispState, dispZip, dispCountry]; static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap; cell.detailTextLabel.numberOfLines = 3; // 0 means no max. cell.detailTextLabel.text = address; return cell; } 
+4
source share
1 answer

To set all cells to the same fixed height, in viewDidLoad or in another suitable place, do:

 self.tableView.rowHeight = 100; 

To set cells to different heights based on the pointer path, use the delegate method heightForRowAtIndexPath:

 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if ((indexPath.section == 0) && (indexPath.row == 0)) return 100; else return 44; } 
+3
source

All Articles