こんにちは、私は内部にいくつかのセルを持つ通常の UITableViewController を持っています。私はこのプロパティを持つセルを 1 つだけ持っています:
cell.backgroundColor = [UIColor lightGrayColor];
セルに灰色が表示されます(良い)。
問題は、スクローラーを使用するときに発生します (ウィンドウをタップして、他のセルを表示するために下に移動します)。この場合、セルのグレー色が (めちゃくちゃ) 位置から別のセルに移動します。
どうして ??
コード:
static NSString *CellIdentifier = @"セル";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(cell.backgroundColor == [UIColor lightGrayColor])
{
cell.backgroundColor = [UIColor lightGrayColor];
}
else
{
cell.backgroundColor = [UIColor clearColor];
}
switch (currentStatus) {
case KBI_NAME:
{
switch (indexPath.section) {
case 0:
{
if(indexPath.row == 0)
{
if (currentUser.currentKBI != nil && ![currentUser.currentKBI isEqualToString:@""]) {
cell.textLabel.text = currentUser.currentKBI;
}
else{
cell.textLabel.text = @"asdf";
}
cell.userInteractionEnabled = NO;
cell.backgroundColor = [UIColor lightGrayColor];
}
if(indexPath.row == 1)
{
cell.textLabel.text = @"xyz";
cell.textLabel.textAlignment = UITextAlignmentCenter;
}
break;
}
case 1: