iPhone Address Book layout

Discussion in 'Mac Programming' started by ace2600, Mar 16, 2008.

  1. macrumors member

    Joined:
    Mar 16, 2008
    Location:
    Austin, Texas
    #1
    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?
     
  2. macrumors 6502

    Joined:
    Feb 16, 2007
    Location:
    Waterloo, Ontario
    #2
    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
     
  3. thread starter macrumors member

    Joined:
    Mar 16, 2008
    Location:
    Austin, Texas
    #3
    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 == && indexPath.row == 0) {
            return 
    100;
        }
        
    //Default row height
        
    return 50;
    }
     

Share This Page