:)
我的表格视图有问题。所有包含任何内容的单元格都被白色覆盖:(
如果我按住一个单元格,我可以看到单元格标签、图像等;浅灰色(这很好)。如果我释放(停止按住它),单元格将按应有的方式推送到下一个视图。
我忘记了什么?为什么我的细胞被白色覆盖?这适用于 iOS 6 :-)
(对不起我的英语不好,截图也有丹麦文字;-))
我在 .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;
我的代码在 .m 下
- (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;
}