views:

41

answers:

1

Hi, I have a view for the iPhone that is basically split in two, with an informational display in the top half, and a UITableView for selecting actions in the bottom half. The problem is that there is no border or separator above the first cell in the UITableView, so the first item in the list looks funny. How can I add an extra separator at the top of the table, to separate it from the display area above it?

Here's the code to build the cells - it's pretty straightforward. The overall layout is handled in a xib.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    switch(indexPath.row) {
        case 0: {
            cell.textLabel.text = @"Action 1";
            break;
        }
        case 1: {
            cell.textLabel.text = @"Action 2";
            break;
        }
        // etc.......
    }
    return cell;
}
A: 

The UITableView lets you customize many things:

  • the table header
  • the section header
  • the section footer
  • etc.

Take a look at the UITableView Programming Guide and the sample applications. You will find out how to customize the UITableView appearance.

Laurent Etiemble
Thanks, the Apple docs are great, but I couldn't find anything on this specific question - how to add another separator line at the top. So I ended up changing my design - went with the Grouped style for my table, and the information display at the top is one group, and the action list at the bottom is another group. This looks 1000x better than the original design (love the rounded corners) so I am sticking with it.
richt