views:

26

answers:

1

I'm managed to make my UITableView rows / cells black when data is loaded, to a fashion, I get a white line in between rows, which makes it look awful. How can i make them fully black with and without data ?

Heres the code I'm using at the moment

- (void)tableView:(UITableView *)tableView willDisplayCell:
        (UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor blackColor];

}

Heres what I get (with white lines remaining) :(

alt text

+3  A: 

Change the separator style of your table view.

yourTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

You can do it in Interface Builder too on the properties palette.

-- Edit for clarity following comments below --

Set the entire tableView to have a black background:

[yourTableView setBackgroundColor:[UIColor blackColor]];

This can also be done in the Interface Builder properties panel.

dannywartnaby
OK cool, what about when there is no data ?
Jules
Have you tried it? :)
dannywartnaby
I see. So set the background colour of your entire table to be black.
dannywartnaby
Ahhh - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { [tableView setBackgroundColor:[UIColor blackColor]]; // Return the number of sections. return 1;}
Jules
I mean literally you need to set the background colour of your table to be black. [yourTableView setBackgroundColor:[UIColor blackColor]]; You can't influence the colour using table cells when there are no cells; so set the table's background colour and you're good to go.
dannywartnaby
You only need to do it once, so do it in IB or once your view controller has loaded the view. There's no need to do it in numberOfSectionsInTableView as that will be called frequently as part of the UITableView's default behaviour.
dannywartnaby