Iphone 重新加载数据不';t在tableview中绘制单元格
这是我的代码,您可以看到我在ViewDidDisplay中重新加载数据show1是我的数据,需要放入detailLabel.text中tableView的单元格中。现在不要看我的奇怪的手机部分,因为它是不可用的atm。我只有一个手机,而且是偶数手机。现在我的问题是当我删除[self.tableView reloadData]时;行,它工作正常,不更新,但它显示单元格。当我放置它时,我在tableView中看不到单元格,它都是空的,知道为什么吗?我哪里做错了 编辑1:Iphone 重新加载数据不';t在tableview中绘制单元格,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,这是我的代码,您可以看到我在ViewDidDisplay中重新加载数据show1是我的数据,需要放入detailLabel.text中tableView的单元格中。现在不要看我的奇怪的手机部分,因为它是不可用的atm。我只有一个手机,而且是偶数手机。现在我的问题是当我删除[self.tableView reloadData]时;行,它工作正常,不更新,但它显示单元格。当我放置它时,我在tableView中看不到单元格,它都是空的,知道为什么吗?我哪里做错了 编辑1: - (void)viewDi
- (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;
}
好的,我把它改了,然后把它从if中取出来,但是我仍然看不到任何表单元格,它都是空的,只有导航栏名称和空单元格。为什么anyidea为空?字符串值
Show1
仅在初始化单元格时设置
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;
将上面的线放在这条线的下面并检查
cell.detailTextLabel.text=show1;
字符串值
Show1
仅在初始化单元格时设置
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;
将上面的线放在这条线的下面并检查
cell.detailTextLabel.text=show1;
代码“cell.detailTextLabel.text=show1;”位于if(cell==nil)的if条件内
重新加载单元格时,如果单元格已可用,则不会进入代码块,并且不会显示更改后的show1值
代码cell=[tableView-dequeueReusableCellWithIdentifier:@“EvenCell”]代码>
检查其是否为可重复使用的单元。如果找到,则返回相同的代码“cell.detailTextLabel.text=show1;”位于If(cell==nil)的If条件内
重新加载单元格时,如果单元格已可用,则不会进入代码块,并且不会显示更改后的show1值
代码
cell=[tableView-dequeueReusableCellWithIdentifier:@“EvenCell”]代码>
检查其是否为可重复使用的单元。如果它发现,那么它将返回相同的你是对的,伙计,我删除了If语句,但仍然没有放置单元格我看到空页,如果你想,我可以放置图像解决方案是不删除If语句,但是在if条件之后添加cell.detailtextlab.text=show1
语句,该条件正好位于cell.textlab.text=[array objectAtIndex:indexPath.row]之上代码>。另外,当您尝试重新加载数据时,您是否可以检查show1的值,以及详细文本颜色是否与您正在设置的背景颜色不同您是对的,伙计我删除了if语句,但仍然没有放置单元格我看到了空页如果您需要,我可以放置图像解决方案是不删除if语句,但是在if条件之后添加cell.detailtextlab.text=show1
语句,该条件正好位于cell.textlab.text=[array objectAtIndex:indexPath.row]之上代码>。另外,当您尝试重新加载数据时,您是否可以检查show1的值,以及详细文本颜色是否与您正在设置的背景颜色不同您是right mate,但我仍然看不到单元格它仍然是空的,其中没有单元格您是right mate,但我仍然看不到单元格它仍然是空的里面没有细胞