Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView不显示数据_Ios_Xcode_Uitableview - Fatal编程技术网

Ios UITableView不显示数据

Ios UITableView不显示数据,ios,xcode,uitableview,Ios,Xcode,Uitableview,我正在实现一个动态表视图。通过触摸另一个视图控制器上的按钮,可将该表视图控制器推入。但即使日志指示单元格行设置正确,屏幕上也不会显示任何内容。原因可能是什么?我已经实现了1节的数量。以下是表视图控制器中的代码: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } } -(UITableViewCell*)tableVie

我正在实现一个动态表视图。通过触摸另一个视图控制器上的按钮,可将该表视图控制器推入。但即使日志指示单元格行设置正确,屏幕上也不会显示任何内容。原因可能是什么?我已经实现了1节的数量。以下是表视图控制器中的代码:

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

}

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“PlayerName”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
if(indexPath.row

}

将tableView推到屏幕上后,尝试调用[tableInstanceName reloadData]

是否已在interface builder中将表的数据源和委托链接到此控制器?请共享将表视图添加到其父视图的代码。如果单元格加载正常,则问题不在委托方法中。此表视图控制器中只有一个表视图。playerNames数组内容在ViewDidLoad中初始化:您能解释一下为什么需要设置tableview委托和数据源,以及在interface builder中的什么位置吗?此时这是一个只读表。好的,我已将表视图的委托和数据源设置为指向表视图控制器。但是它甚至不再执行viewdidload了。当我读到viewdidload没有被调用时,它也从viewdidload中删除了playerNames初始化。因此,在prepareforsegue中调用表视图控制器上名为setplayernames的方法。这也不行-为什么不加载表数据?请帮忙。好的,我想好了。我已经删除了导航控制器,没有它segues就不能工作。因此,网络是在设置tableview的委托和数据源之后工作的。谢谢
- (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;