iphonesdkgrouped-table

How do I push grouped tables down in the view on the Iphone?


Below shows the default position when you add a grouped table to a view? How do I push the entire grouped table down in the view?

alt text
(source: pessoal.org)


Solution

  • You can assign a transparent view with a fixed height to the tableHeaderView property of the tableView. This will push the table contents down by the height of the transparent view.

    You can do this from your UITableViewController's viewDidLoad:

    // force the table down 70 pixels
    CGRect headerFrame = self.tableView.bounds;
    headerFrame.size.height = 70;
    
    UIView *header = [[UIView alloc] initWithFrame: headerFrame];
    header.backgroundColor = [UIColor clearColor];
    
    self.tableView.tableViewHeader = header;
    
    [header release];