:)
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;
}