[英]iPhone - 3 UITableViews with Custom cell
我有一个3 Table视图的视图。 每个表视图将使用一个“自定义单元格视图”。 我正在使用以下代码。 但是它仅显示一个表格视图。 有人可以指出我为什么吗? (所有数组都填充有必要的对象)
- (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;}
您有2个选择。
希望能有所帮助。 如果您将添加所有数据源和委托方法,那么更多的人将尝试提供帮助。
问题可能出在重用标识符上。 由于您对所有表视图都使用具有相同标识符的单元格,因此,我认为这是问题的原因。 我也以相同的方式解决了这个问题。 为每个具有不同标识符的表视图创建单独的单元格,然后重用它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.