Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.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
iPhone-3带自定义单元格的UITableView_Iphone_Uitableview - Fatal编程技术网

iPhone-3带自定义单元格的UITableView

iPhone-3带自定义单元格的UITableView,iphone,uitableview,Iphone,Uitableview,我有一个有3个表视图的视图。 每个表视图将使用一个自定义单元格视图。我正在使用以下代码。但它只显示一个表视图。有人能告诉我为什么吗?所有数组都填充了必要的对象 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellID = @"CustomSyncCell"; CustomCellView* cell

我有一个有3个表视图的视图。 每个表视图将使用一个自定义单元格视图。我正在使用以下代码。但它只显示一个表视图。有人能告诉我为什么吗?所有数组都填充了必要的对象

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellID = @"CustomSyncCell";
CustomCellView* cell = (CustomCellView*)[tableView dequeueReusableCellWithIdentifier:cellID];

if(cell == nil)
{
    NSArray* nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellView" owner:nil options:nil];
    for(id currentObject in nibObjects)
    {
        if([currentObject isKindOfClass:[CustomCellView class]])
        {
            cell = (CustomCellView*)currentObject;
        }
    }       
}

ObjectDetails* obj;
if(tableView == phoneNumbersTable)
{
    obj = [phoneNumbersArray objectAtIndex:indexPath.row];
}
else if(tableView == mailIDsTable)
{
    obj = [mailIDsArray objectAtIndex:indexPath.row];
}
else if(tableView == socialUpdatesTable)
{
    obj = [socialUpdatesArray objectAtIndex:indexPath.row];
}   

cell.keyLabel.text = [self returnPhoneType:obj.objKey];
cell.valueLabel.text = obj.objValue;        

return cell;}
你有两个选择

在TableView上以及在dataSource和Delegates方法测试中为该标记设置标记属性。 创建3个对象,每个对象都设置为特定的tableView委托和数据源,并将代码放入该对象中。
希望有帮助。如果您将添加所有数据源和委托方法,更多的人将尝试提供帮助。

问题可能在于重用标识符。由于所有表视图都使用具有相同标识符的单元格,所以我认为这就是问题的原因。我也用同样的方式解决了这个问题。为每个具有不同标识符的tableview创建单独的单元格并重用它们。

三个单元格是否同时可见?是否为所有三个表视图设置了委托和数据源?NumberOfSectionsTableView和numberOfRowsInSection方法看起来像什么?是的,这三种方法一次都可见。对于所有TableView,都设置了委托和数据源。表视图中的节数为1,行数为数组计数。对于选项1:我直接检查表视图,因此标记有何帮助。对于选项2:我认为这不是正确的方法。