I have a UITableView in my project with rows being initialised as default UITableViewCell (the owner file is the delegate and the datasource for the table):
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
switch (indexPath.row) {
case 0:
cell.imageView.image = [UIImage imageNamed:@"icon_facebook.png"];
cell.textLabel.text = kShareFacebook;
break;
case 1:
cell.imageView.image = [UIImage imageNamed:@"icon_twitter.png"];
cell.textLabel.text = kShareTwitter;
break;
case 2:
cell.imageView.image = [UIImage imageNamed:@"icon_clipboard.png"];
cell.textLabel.text = kShareClipboard;
break;
default:
break;
}
return cell;
}
This all works fine, however when the table is displayed, the images are shown on a darker background and there is a darker margin along the right edge of the rows, as can be seen in this image:

I’ve tried to clear that background using a combination of some/all:
[cell setBackgroundColor:[UIColor whiteColor]];
[cell.imageView setBackgroundColor:[UIColor whiteColor]];
[cell setIndentationLevel:1];
[cell setOpaque:YES];
however this didn’t help a bit. How can I get rid of the dark background so that the entire cell appears on white background?
This must have been one of iOS or, most likely, XCode’s fluckes. I deleted the table in IB and delete the corresponding code in my
.mfile. I then saved and closed the project and quit XCode.After opening XCode and the project, I open the ViewController in IB again and added the table again and set up all the delegates again. I added the code to set the overall table’s background to transparent (this can’t be done via IB, so I put that code in
viewDidLoadmethod). I then rewrote thecellForRowAtIndexPathmethod (no copy-paste, just re-typed it – no problem, only about 10 lines anyway) and build the project.Lo and behold: the table was now displaying correctly. I hate spending days on some stupid bugs in the development tools.