Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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_Ios_Objective C_Uitableview - Fatal编程技术网

显示过多单元格的表视图-IOS

显示过多单元格的表视图-IOS,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有带有图像和文本的tableview单元格。第一个单元格有一个图像(表单元格0),但数组中的文本从第二个单元格(表单元格1)开始。最后一个单元格有文本,但没有图像 文本数组从0开始,表格单元格从0开始,因此第一个单元格应该有第一个文本数组 任何想法: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"RUNNING

我有带有图像和文本的tableview单元格。第一个单元格有一个图像(表单元格0),但数组中的文本从第二个单元格(表单元格1)开始。最后一个单元格有文本,但没有图像

文本数组从0开始,表格单元格从0开始,因此第一个单元格应该有第一个文本数组

任何想法:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"RUNNING %d",indexPath.row);
    static NSString *CellIndentifer = @"CustomTableCell";
    CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIndentifer];

   if (cell == nil)
   {
     cell = [[CustomTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifer];
    }

    if (allLogos.count > indexPath.row) {
        [self loadimage:[allLogos objectAtIndex:indexPath.row] row:indexPath];
    }
    else {
        cell.imageView.image = nil;
    }


    cell.tabledeallabel.text = [allcontent objectAtIndex:indexPath.row];
    cell.tablebarlabel.text = [allname objectAtIndex:indexPath.row];


    return cell;

}

您说过“数组中的文本从第二个单元格(表单元格1)开始”。看起来你应该这样做:

NSInteger textIndex = indexPath.row - 1;
if (textIndex >= 0) {
    cell.tabledeallabel.text = allcontent[textIndex];
    cell.tablebarlabel.text = allname[textIndex];
}

您返回的数字是多少?显示为15,这是正确的。。但这段文字是在下面一段,在后面一段结束。。开车送我上厕所!!!一个屏幕截图将很好地形象化这种情况。屏幕截图有什么不正确的地方?文本没有出现在第一个单元格中。。尽管它在表视图中为0,在ArrayTanks中为0,但我已经尝试过了,它不起作用,因为我认为编号是正确的,我认为一个恶意单元格出现在顶部。为什么它会显示一个单元格?