2011-12-02 7 views
1

나는이 방식으로 상단에 다른보기를 추가하는 뷰가 있습니다cellForRowAtIndexPath가 호출되지

- (void)showAreaEditView { 

    NSLog(@"SHOWING AREA EDITOR VIEW"); 

    if (self.thisAreaEditorView == nil) { 

     // Create View 
     AreaEditorView *tmpViewController = [[AreaEditorView alloc] initWithNibName:@"AreaEditorView" bundle:nil]; 
     self.thisAreaEditorView = tmpViewController; 
     [tmpViewController release]; 

     // Hide the back button 
     self.thisAreaEditorView.navigationItem.hidesBackButton = YES; 

    } 

    self.thisAreaEditorView.myInspectionID = self.myInspectionID; 
    self.thisAreaEditorView.loggedIn = loggedIn; 
    self.thisAreaEditorView.loggedInGroup = loggedInGroup; 

    // Slide view up 

    [self.view addSubview:thisAreaEditorView.view]; 


    CGRect endFrame = CGRectMake(self.view.frame.size.width/2 - thisAreaEditorView.view.frame.size.width/2, 
           self.view.frame.size.height/2 - thisAreaEditorView.view.frame.size.height/2, 
           thisAreaEditorView.view.frame.size.width, 
           thisAreaEditorView.view.frame.size.height); 

    CGRect startFrame = endFrame; // offscreen source 

    // new view starts off bottom of screen 
    startFrame.origin.y += self.view.frame.size.height; 
    self.thisAreaEditorView.view.frame = startFrame; 

    // start the slide up animation 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:.6]; 
    thisAreaEditorView.view.frame = endFrame; // slide in 
    [UIView commitAnimations]; 

} 

을 내가 방금 슬라이드 부분을 무시할 수 있습니다 확신, 나는 addSubview 관련성 생각합니다.

다음이 thisAreaEditor에서 나는 테이블과 버튼 등으로 볼 수 있습니다. UITableView 대리인/데이터 원본 파일의 소유자 정상적으로 가고있다.

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

    NSLog(@"numberOfRowsInSection returning %d", [tableData count]); 
    [tableData count]; 

} 

이 기능 numberOfRowsInSection 4

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Configure the cell... 
    NSString *thisText = [tableData objectAtIndex:indexPath.row]; 
    cell.textLabel.text = thisText; 

    NSLog(@"looking at cell %d text:%@", indexPath.row, thisText); 

    return cell; 

} 

를 반환하지만 cellForRowAtIndexPath가 호출되지 없구요.

저는 여기에 손실이 있습니다. 어떻게 작동하는지 잘 모르지만 대리자 기능 중 하나는 단순히 호출되지 않습니다.

나는 [bigTable reloadData] 등을 시도했지만, 테이블은 채워지지 않고 함수 출력의 로그는 표시되지 않습니다.

미리 감사드립니다.

답변

8

죄송 합니다만 tableData의 개수를 잊어 버린 것 같습니다.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    NSLog(@"numberOfRowsInSection returning %d", [tableData count]); 
    return [tableData count]; 
} 
+0

오, 내 말이 맞아. 'numberOfRowsInSection'에서'return'을 놓치고있었습니다. 그것을 믿을 수 없다는 것은 간단합니다, 고마워요! – Batnom

+0

메신저 8 개의 다른 섹션을 처리하기 위해'numberOfRowsInSection'의 switch 문을 사용합니다. 'return'이라는 단어를 빼먹었습니다. 어떤 문제들은 너무 바보로 풀릴 수 있습니다. – lizzy81

0

아마도 self 또는 datasource 자체로 tableView 대리인을 설정하지 않았습니다. 지금 작동하는 경우 & 볼이 코드를 추가 - 헤더 파일에 또한

[tableView setDelegate:self]; 
[tableView setDataSource:self]; 

이 대표단을 상속 -이 도움이 UITableViewDelegate, UITableViewDataSource

@interface yourViewController: UIViewController <UITableViewDelegate, UITableViewDataSource> 

희망을.

+0

여전히 불행하게도 작동하지 않습니다.'viewWillAppear'에서'[bigTable reloadData]'를 트리거하는'populateTableData' 함수를 호출하므로'titleForHeaderInSection'이 호출되고 (아무것도 반환하지 않습니다),'numberOfRowsInSection' (4를 반환합니다)이옵니다. – Batnom

3

UITableViewDelegate가 누락 된 것 같습니다.

인터페이스 빌더를 사용하는 경우 테이블 뷰 아웃렛을 마우스 오른쪽 버튼으로 클릭하고 delegatedatasource을 모두 File's Owner으로 드래그하십시오. 당신이 당신의있는 tableView

bigTable.delegate = self; 
bigTable.dataSource = self; 

이 Srikar 말하는대로의 UITableViewDelegate 및 UITableViewDataSource 프로토콜을 가져 기억 init이 곳

그리고 만약

은 인터페이스 빌더이 추가 사용하지.

희망은 도움이됩니다.

건배!

0

이 링크는 이전 링크이지만이 문제를 해결 한 방법에 대한 정보를 입력하여 업데이트하고 싶습니다. 저에게있어서 문제는 cellForRowAtIndexPath가 호출되지 않도록 테이블에 0 행을 채우는 배열이었습니다. 테이블을 채우는 데 사용중인 배열에 데이터가 들어 있는지 확인하십시오.

관련 문제