私は2つのセル(カスタムtableviewcells)とログイン用のボタンを持つuitableviewを持っています。私はプログラムで作った。今度は、2つのカスタムセルとボタンの背後に背景画像を配置したいと思います。私はIBに入り、画像ビューをテーブルビューの上に置き、背景として必要な画像を置く。次に私はviewDidLoad
に入り、このビットをコードtblSimpleTable.backgroundColor = [UIColor clearColor];
に入れて、tableviewsの背景色をクリアします。UITableViewに背景画像が表示されない
それは次のようになります。
しかし、背景は表示されません。誰もがこれを修正する方法を知っていますか?
ありがとうございました。
のviewDidLoadあなたはUITableView
オブジェクトのbackgroundView
プロパティを使用していないのはなぜ
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSourceArray = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"UITextField", kSectionTitleKey,
@"TextFieldController.m: textFieldNormal", kSourceKey,
self.textFieldNormal, kViewKey,
nil],
nil];
UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
loginButton.frame = CGRectMake(60,140,200,38); // position in the cell and set the size of the button
[loginButton setTitle:@"Login" forState:UIControlStateNormal];
// add targets and actions
[loginButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
// add to a view
[self.view addSubview:loginButton];
tblSimpleTable.backgroundColor = [UIColor clearColor];
//tblSimpleTable.backgroundView = nil;
//UIImageView *imageView = [[UIImageView alloc] initWithImage:@"Background-Red.png"];
//imageView.frame = tblSimpleTable.frame;
//tblSimpleTable.backgroundView = imageView;
self.title = NSLocalizedString(@"TextFieldTitle", @"");
// we aren't editing any fields yet, it will be in edit when the user touches an edit field
self.editing = NO;
}
に
を追加しますか?どのようにこれをやったのか、いくつかのコードを見せてくれますか? – Manuel
ImageViewとそのImageViewにラベルとすべてのものをNibファイルに入れます –
@ dragon112 + Marvin:** viewDidLoad **のコードは上記のようになります。 –