我正在实现一个动态表视图。这个表视图控制器是通过另一个视图控制器上的按钮触摸推入的。但是,即使日志表明单元格行设置正确,屏幕上也不会显示任何内容。可能是什么原因?我已经实现了部分的数量为 1。这是表格视图控制器中的代码:
- (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;
}