2012-06-22 4 views
0

스토리 보드에는 작성되지 않았지만 코드별로 UITableView가 작성되었습니다. 이 테이블은 다른 샹들리에를 선택하여 새로 고칠 수 있지만 이전 데이터가있는 다른 테이블이있을 때 ... 새로 고침을하는 시간이 거의 없습니다 ...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; 

답변

0

이에 불가능하다, 여기에/

행에 대한 셀의 코드는,하지만 난이 문제라고 생각하지 않습니다 :정말 코드로 문제를 찾을 수없는 문제가 무엇인지 정확히 말하십시오. 그러나 매번 테이블보기를 다시 작성하는 경우 [tableView removeFromSuperview]을 nil로 설정하기 전에 확인해야합니다.

+0

그래, 내가 superview에서 그것을 제거하고 나서 새로운 테이블이 올바르게 채워지지만 거기에 오래된 것을 ... 그래서 그것은 터치 이벤트를 얻을 수 있지만 그것을 다시 시작합니다. –

+0

Imma 업로드 코드 –

0

귀하의 질문에 조금 이해하기 힘들지만 여기에 그것을 가지고 있습니다.

테이블보기의 '내부'데이터를 새로 고칩니다. 그렇다면 새 UITableView를 만들 필요가 없습니다. reloadData을 호출하면 UITableView는 새로운 데이터를 위임하고 데이터 소스를 쿼리합니다.

새 UITableView 인스턴스를 추가했지만 데이터 소스 및 위임 메소드에서 동일한 데이터를 반환하면 이전 데이터 만 표시됩니다. 메소드를 업데이트했는지 확인하십시오.

+0

내가 다시로드 한 데이터를 가지고 있으며, 이전 데이터가있는 두 번째 테이블이 있습니다. 이미지를 게시 할 수 없으므로 문제가 발생합니다. Pd : 내 영어 XD에 대한 죄송합니다. –

+0

Did 대리자 및 데이터 소스 메서드를 업데이트하여 새 데이터를 반환합니까? – Rengers

+0

예, 목록을 다시 만들 때와 같은 결과가 나타납니다. –