2009-10-19 2 views
1

내 문제는 아주 단순 해 보이지만 여기 또는 다른 해결책을 찾지 못했습니다. 내 UIView 중 하나에 서브 클래스로 UITableView이 있습니다. 응용 프로그램이 끝나면 마지막으로 선택한 표 셀이 NSUserDefaults에 저장되고 응용 프로그램이 다시 시작되면 이전에 선택된 셀을 설정하려고합니다. 그러나 섹션 수를 알 수 없으므로 너무 일찍 처리 할 때 문제가 발생합니다. 즉, 테이블에 아직 데이터가로드되지 않았습니다. 그래서 작동하는 numberOfRowsInSection 함수로 설정하기로 결정했는데,이 작업을 수행하는 올바른 위치가 아닌 것은 확실합니다.언제 UITableView 업데이트가 완료 되었습니까?

- (NSInteger)tableView:(UITableView *)tableView 
    numberOfRowsInSection:(NSInteger)section 
{ 
    int iNofRows = 0; //Default 

    // It is not great doing this here but.... 
    if(bSetDefaultSelection == YES) 
    { 
     bSetDefaultSelection = NO; // Stop recursion 
     **NSIndexPath* indexPath = [NSIndexPath indexPathForRow:(NSUInteger)l last_sel_row inSection:(NSUInteger)0]; 
     [self selectRowAtIndexPath:indexPath animated:NO          scrollPosition:UITableViewScrollPositionMiddle];** 
    } 
    return iNofRows; 
} 

답변

4

나는 당신이 찾고있는 장소가

- (void)viewDidAppear:(BOOL)animated;  
// Called when the view has been fully transitioned onto the screen. Default does nothing 

난 그냥 내 응용 프로그램을 디버깅 한 를 (자세한 내용은 UIViewController에 참조)라고 생각하고 그 방법은 당신이했습니다 한 후라고합니다 언급 :

:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

를 귀하의 경우에는 당신이 뭔가를 작성해야 할 것

건배!

0

답장을 보내 주셔서 감사합니다. 아무도 노력에 감사하지 않는다고 생각했습니다. '(void) viewDidAppear : (BOOL) animate'솔루션은 UITableViewController에서만 작동하지만 UITableView를 다루고 있습니다. 하지만 주 컨트롤러에서 테이블을 선택하여 트리거하는 알림을 게시하기로 결정했습니다. 다시 한번 감사드립니다.

관련 문제