View Full Version : iPhone Address Book layout

Mar 16, 2008, 11:55 PM

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?

Mar 17, 2008, 12:47 AM
UITableViewDelegate looks like the answer for this one. It contains the following:

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

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

Luke Gladding

Mar 17, 2008, 09:33 AM
Thanks, that worked!

For anyone new to this, here is an example implementation:- (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;