2010-08-18 6 views
1

사용자가 터치 할 때 "로그인 테이블"(사용자 이름과 암호 및 세션 세션 셀에 대해 UITextField가 포함 된 테이블)에서 이동해야하는 UITableViewController 하위 클래스로 작업하고 있습니다. "세션 시작"셀 UITableViewController를 다시로드하고 "로그 아웃"레이블이있는 셀 하나만 표시해야합니다.UITableView 데이터 재로드 문제

문제는 내가 정보를 새로 고침 할 때 일부 셀이 파란색으로 표시된 "선택됨"으로 나타나고 일부 셀에는 제목이 없습니다.

[[self tableView] beginUpdates]; 
    [[self tableView] deleteSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationTop]; 
    [[self tableView] insertSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 0)] withRowAnimation:UITableViewRowAnimationTop]; 
    [[self tableView] endUpdates]; 

이있는 테이블에 내가 바꿀 것 범위를 다시로드거야하지만 기본적인 생각 따라 내가 놓친 거지 뭔가가있다 :

나는 이런 식으로 테이블을 다시로드 무엇입니까?

답변

1
[[self tableView] beginUpdates]; 
[[self tableView] deleteSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 0)] withRowAnimation:UITableViewRowAnimationBottom]; 
[[self tableView] insertSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationBottom]; 
[[self tableView] endUpdates]; 

[[self tableView] beginUpdates]; 
[[self tableView] reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationBottom]; 
[[self tableView] endUpdates]; 

[[self tableView] reloadData]; 

그 방법 조합이 작동하는 것처럼 보입니다. 나도 잘 모릅니다. 더 나은 해결책을 찾을 때까지는 이렇게 남겨 둘 것입니다.

+0

어쩌면 내가 여기에 뭔가 빠졌어 ... 왜 [[self tableView] reloadData]를 호출하지 않는가? 다른 모든 것은 건너 뜁니다. – maxpower

+0

@maxpower 이것은 잘 움직입니다. – Moshe