Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ace2600

macrumors member
Original poster
Mar 16, 2008
71
0
Austin, Texas
Hi,

I am looking at getting a similar layout to the Contact's Info page on the iPhone (Phone->Contacts->Joe Smith->.)

I know setting UITableView's style to UITableViewStyleGrouped achieves the rounded table look seen with the phone numbers, email, and address. So my thought is to use a UITableView with multiple sections, for say numbers, email, and the address.

When initializing the UITableView you can set rowHeight to whatever height for all rows in the table. That's fine and dandy for phone numbers and email as they are the same height and can use same height rows. But the address section is one tall row (street, city, state, etc.).

How do you set just one section's rowHeight to a larger value?
 

lucasgladding

macrumors 6502
Feb 16, 2007
319
1
Waterloo, Ontario
UITableViewDelegate looks like the answer for this one. It contains the following:

Code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

Haven't tried it yet myself, but I expect this is the method you want.

Luke Gladding
 

ace2600

macrumors member
Original poster
Mar 16, 2008
71
0
Austin, Texas
Thanks, that worked!

For anyone new to this, here is an example implementation:
PHP:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //Row height for all rows in second section
    if(indexPath.section == 1) {
        return 75;
    }
    //Row height for third section's first row
    if(indexPath.section == 2 && indexPath.row == 0) {
        return 100;
    }
    //Default row height
    return 50;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.