我有一个 UITableView 不是在情节提要中创建的,而是通过代码创建的。可以通过选择其他一些冠军来刷新此表,但是当我这样做时,还有另一个包含旧数据的表...我在刷新时设置为零...
有人有想法吗??
要填写表格,我使用此代码
listVideo = [listGroupes objectAtIndex:indexPath.row];
montageListView= [[UITableView alloc] initWithFrame:listFrame style:UITableViewStylePlain];
montageListView.delegate = self;
montageListView.dataSource = self;
montageListView.layer.cornerRadius = 10;
[listMontagesView addSubview:montageListView];
所以有一个带有其他选项的新视图,但是如果我返回此代码:
montagesListView removeFromSuperview];
montagesListView = nil;
我用相同的代码重新填充它
listVideo = [listGroupes objectAtIndex:indexPath.row];
montageListView= [[UITableView alloc] initWithFrame:listFrame style:UITableViewStylePlain];
montageListView.delegate = self;
montageListView.dataSource = self;
montageListView.layer.cornerRadius = 10;
[listMontagesView addSubview:montageListView];
还有一张好表,但还有一张旧数据……我真的没有发现代码有问题:/
这是行的单元格代码,但我认为这不是问题,
static NSString *MyIdentifier = @"MyIdentifier";
NSString *text;
// Try to retrieve from the table view a now-unused cell with the given identifier.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
// If no cell is available, create a new one using the given identifier.
if (cell == nil) {
// Use the default cell style.
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:MyIdentifier];
}
if (tableView == groupListView) {
text = [listGroupesNames objectAtIndex:indexPath.row];
}else {
text = [[listVideo objectAtIndex:indexPath.row]description];
if ([[listVideo objectAtIndex:indexPath.row]note] == 1) {
cell.imageView.image = [UIImage imageNamed:@"good.png"];
}
if ([[listVideo objectAtIndex:indexPath.row]note] == 2) {
cell.imageView.image = [UIImage imageNamed:@"neutre.png"];
}
if ([[listVideo objectAtIndex:indexPath.row]note] == 3) {
cell.imageView.image = [UIImage imageNamed:@"bad.png"];
}
}
if ([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
cell.textLabel.font=[UIFont systemFontOfSize:18.0];
text = [NSString stringWithFormat:@" %@",text];
}else{
cell.textLabel.font=[UIFont systemFontOfSize:12.0];
}
if (tableView == groupListView) {
cell.imageView.image = [UIImage imageNamed:@"group.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
if(tableView == montageListView){
cell.imageView.image = [UIImage imageNamed:@"videos.png"];
}
cell.textLabel.text = text;
return cell;