1

:)

テーブルビューに問題がありました。コンテンツを含むすべてのセルが白でオーバーレイされます:(

セルを長押しすると、セルのラベルや画像などが表示されます。薄い灰色で(これは良いです)。離すと(押し続けるのをやめる)、セルは次のビューにプッシュされます。

私は何を忘れていますか?セルが白で覆われているのはなぜですか? これは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;
}

テーブルビューを備えたビューコントローラー:

セルを押すと:

4

1 に答える 1

3

この質問を見てください: UITableView clear background in iOS 7 UITableViewCells のデフォルトの背景色は、パフォーマンス上の理由によりからclearColorに変更されました。whiteColor

必要に応じて変更するcell.contentView.backgroundColor = [UIColor clearColor]必要があります。

于 2013-11-10T12:58:41.183 に答える