동적 테이블 뷰를 구현 중입니다. 이 테이블 뷰 컨트롤러는 다른 뷰 컨트롤러의 버튼 터치를 통해 푸시됩니다. 그러나 로그가 셀 행이 올바르게 설정되었음을 나타내더라도 화면에는 아무 것도 표시되지 않습니다. 그 이유는 무엇일까요?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;
}
인터페이스 빌더에서 테이블의 데이터 소스를 연결하고이 컨트롤러에 위임 했습니까? –
부모보기에 tableview를 추가하는 코드를 공유하십시오. 셀이 잘로드되는 경우 문제가 대리자 메서드에 없습니다. – KDaker