- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSString *show=[NSString stringWithFormat:@"%@",[res objectAtIndex:18]];
float f=[show floatValue];
show1=[NSString stringWithFormat:@"%.2f %%",f];
[show1 retain];
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.row % 2 == 0) {
// EVEN
cell = [tableView dequeueReusableCellWithIdentifier:@"EvenCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"EvenCell"] autorelease];
UIView *bg = [[UIView alloc] initWithFrame:cell.frame];
UIColor *colour = [[UIColor alloc] initWithRed: (208.0/255.f) green: (231.0/255.f)
blue: (241.0/255.f) alpha: 1.0];
bg.backgroundColor = colour;
cell.backgroundView = bg;
cell.textLabel.backgroundColor = bg.backgroundColor;
[bg release];
cell.detailTextLabel.backgroundColor=[UIColor clearColor];
cell.detailTextLabel.text=show1;
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else {
// ODD
cell = [tableView dequeueReusableCellWithIdentifier:@"OddCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"OddCell"] autorelease];
UIView *bg = [[UIView alloc] initWithFrame:cell.frame];
UIColor *colour = [[UIColor alloc] initWithRed: (143.0/255.f) green: (169.0/255.f)
blue: (180.0/255.f) alpha: 1.0];
bg.backgroundColor = colour;
cell.backgroundView = bg;
cell.textLabel.backgroundColor = bg.backgroundColor;
[bg release];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
これは私のコードです。viewDidAppearでデータをリロードするとわかります。show1は、detailLabel.text内のtableViewのセルに配置する必要があるデータです。さて、私の奇妙な細胞の部分は、それが使えないatmを見ないでください。私は1つのセルとその偶数セルしか持っていません。私の問題は、[self.tableView reloadData]を削除するときです。私はそれを置くときに私はtableViewのセルを見ることができないそのすべての空のアイデアなぜ?どこが間違っているの?reloadDataはテーブルビューでセルを描画しません
EDIT1:私はそれを変更している場合の外にそれを得るが、それでも私は任意のテーブルセルにちょうどナビゲーションバーの名前と空のセルのすべての空を見ることができない
cell.backgroundView = bg;
cell.textLabel.backgroundColor = bg.backgroundColor;
[bg release];
cell.detailTextLabel.backgroundColor=[UIColor clearColor];
}
cell.detailTextLabel.text=show1;
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
オーケー。なぜその空のanyidea?
あなたは右の仲間です私は、あなたは私が画像を置くことができる場合、空のページを参照してください。 –
解決策はif文を削除するのではなく、 'cell.detailTextLabel.text = show1'の文を' cell .textLabel.text = [配列objectAtIndex:indexPath.row]; '。また、データを再読み込みしようとしているときにshow1の値が何であるかを確認することができます。設定している背景色とは異なる詳細テキスト色です –