2012-09-07 8 views
0

동적 테이블 뷰를 구현 중입니다. 이 테이블 뷰 컨트롤러는 다른 뷰 컨트롤러의 버튼 터치를 통해 푸시됩니다. 그러나 로그가 셀 행이 올바르게 설정되었음을 나타내더라도 화면에는 아무 것도 표시되지 않습니다. 그 이유는 무엇일까요?UITableView에 데이터가 표시되지 않습니다.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
// Return the number of sections. 
return 1; 

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
// Return the number of rows in the section. 

NSLog(@"Row count :%d",self.playerNames.count + 1); 
return self.playerNames.count + 1; 

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"PlayerName"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 

if (indexPath.row < self.playerNames.count) { 
    cell.textLabel.text = [self.playerNames objectAtIndex:indexPath.row]; 
} 

NSLog(@"Cell Text :%@",cell.textLabel.text); 
return cell; 

}

+1

인터페이스 빌더에서 테이블의 데이터 소스를 연결하고이 컨트롤러에 위임 했습니까? –

+0

부모보기에 tableview를 추가하는 코드를 공유하십시오. 셀이 잘로드되는 경우 문제가 대리자 메서드에 없습니다. – KDaker

답변

0

후 : 여기 테이블 뷰 컨트롤러의 코드는 1이어야 섹션 수를 구현 귀하의 tableView가 화면에 푸시되고, [tableInstanceName reloadData]를 호출 해보십시오;

+0

이 테이블 뷰 컨트롤러에는 테이블 뷰가 하나만 있습니다. playerNames 배열 내용이 ViewDidLoad : – user1620383

+0

에서 초기화됩니다. 왜 tableview 위임자와 데이터 소스를 설정해야하는지, 인터페이스 작성기에서 어디에 있어야하는지 설명해 주시겠습니까? 현재이 테이블은 읽기 전용 테이블입니다. – user1620383

+0

OK 테이블 뷰 컨트롤러를 다시 가리 키도록 테이블 뷰의 대리자 및 데이터 소스를 설정했습니다. 그러나 더 이상 viewdidload를 실행하지 않습니다. – user1620383

관련 문제