ストーリーボードではなくコードで作成された UITableView があります。このテーブルは、他のチャンピオンを選択することで更新できますが、そうすると、古いデータを含む別のテーブルが表示されます...更新するたびに 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];
別のオプションを持つ新しいビューがありますが、このコードに戻ると:
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;