1

:)

I got a problem with my tableview. All the cells with any content gets overlaid with white :(

If I hold down a cell, I can see the cells label, the image, and so on; in light gray (this is good). If i release (stop holding it down) the cell pushes to the next view which as it should.

What am I forgetting? Why is my cells overlaid by white? This worked in iOS 6 :-)

(Sorry for my bad english and the screenshots are also with danish text ;-))

My code in .h:

#import <UIKit/UIKit.h>

@interface SkabelonerViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {

@private
NSMutableArray *tableData;
NSDictionary *selectedItem;

}

// Tableview stuff
@property (strong, nonatomic) IBOutlet NSArray *tabelData;
@property (strong, nonatomic) IBOutlet UITableView *tableView;

My code in .m under

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}

UIButton *deleteButton;
deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
deleteButton.frame = CGRectMake(650, 10, 30, 30);
UIImage *image = [UIImage imageNamed:@"Trash.png"];
[deleteButton setImage:image forState:UIControlStateNormal];

[deleteButton addTarget:self action:@selector(deleteTemplate:) forControlEvents:UIControlEventTouchUpInside];
deleteButton.tag=indexPath.row;
[cell.contentView addSubview:deleteButton];

// create the label objects
UILabel *sletLabel = [[UILabel alloc] initWithFrame:CGRectZero];
sletLabel.backgroundColor = [UIColor clearColor];
//sletLabel.font = [UIFont boldSystemFontOfSize:12];
[sletLabel setFont:[UIFont boldSystemFontOfSize:12]];
sletLabel.frame = CGRectMake(654,41,25,21);
sletLabel.text =  @"Slet";
sletLabel.textColor = [UIColor whiteColor];
[cell.contentView addSubview:sletLabel];

NSDictionary *dic = [tableData objectAtIndex:indexPath.row];

cell.textLabel.text = [dic valueForKey:@"templatename"];

cell.accessoryView = [[ UIImageView alloc ]

                      initWithImage:[UIImage imageNamed:@"Right-hvid"]];

cell.textLabel.textColor = [UIColor whiteColor];
cell.selectionStyle = UITableViewCellSelectionStyleGray;

[self.tableView setBackgroundColor:[UIColor colorWithRed:37 green:37 blue:37 alpha:0]];

NSString *templateID = [dic valueForKey:@"templateid"];

deleteButton.hidden = NO;
sletLabel.hidden = NO;

return cell;
}

The view controller with my tableview:

When i press the cell:

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mikkel V.
  • 155
  • 1
  • 3
  • 11

1 Answers1

3

Have a look at this question: UITableView clear background in iOS 7 the default background color of UITableViewCells changed from clearColor to whiteColor due to performance reasons.

You should change your cell.contentView.backgroundColor = [UIColor clearColor] if necessary.

Community
  • 1
  • 1
btype
  • 1,593
  • 19
  • 32
  • If it is not that big and the cell height calculation is simple you can use `[self.tableView reloadData]` or `reloadRowsAtIndexPaths:withRowAnimation:` for 1 or more rows. But make sure to update your dataSource first – btype Nov 10 '13 at 13:15
  • Hi again. First of all; thank you for helping me out with my problem before! :) Im unfortunately run into another problem :( I got a button in a cell, and when i press the button i need the index.row for the given cell the button is in. I found a project (http://www.roostersoftstudios.com/2011/05/01/iphone-custom-button-within-a-uitableviewcell/), but it does not work either :( It seems like iOS7/xCode 5 is the problem.. Do you know how i can fix this? Thank you again! -Mikkel Vesterled, 15 years old ;-) – Mikkel V. Nov 10 '13 at 15:43
  • Open up a new question and share your code. This way future seekers will see the correct question with the correct answer! – btype Nov 10 '13 at 16:54
  • I just did ;-) http://stackoverflow.com/questions/19892477/tableview-button-get-index-row – Mikkel V. Nov 10 '13 at 17:06