1

我有 ipad 应用程序,我在其中使用 tableView 显示数据,但问题是它没有在 tableView 中显示数据这里是设置单元格值的代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                   reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleBlue;
    }

    if (tableView == tableCategory) {

        cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
        cell.textLabel.textAlignment=UITextAlignmentLeft;    

        ObjectData*theCellData = [categoryArray objectAtIndex:indexPath.row];
        cell.textLabel.text=theCellData.categoryTitle;

        return cell;
    }
    else if (tableView == tableSubCategory)
    {
        cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
        cell.textLabel.textAlignment=UITextAlignmentLeft;    
        ObjectData*theCellData = [subCategoryArray objectAtIndex:indexPath.row];

        NSString *test = theCellData.subCategoryTitle;
        NSLog(@"Test Cell is %@",test);
        cell.textLabel.text = test;

        return cell;    
    }
    else if(tableView == tablePublish)
    {
        cell.textLabel.font = [UIFont fontWithName:@"Arial" size:16];
        cell.textLabel.textAlignment = UITextAlignmentLeft;    

        GetPublishData *theCellData = [publishArray objectAtIndex:indexPath.row];
        NSString *test = [NSString stringWithFormat:@"%@:%@:%@ in:%@:%@",theCellData.UserName,theCellData.ContentTitle,theCellData.ContentType,theCellData.Catgeory,theCellData.SubCategory];
        NSLog(@"Test Cell is %@",test);
        cell.textLabel.text = test;
        cell.detailTextLabel.text = theCellData.ContenAddedTime;

        return cell;
    }
    else
    {
        cell.textLabel.font = [UIFont fontWithName:@"Arial" size:16];
        cell.textLabel.textAlignment = UITextAlignmentLeft;  

        GetPublishData *theCellData = [publishArray objectAtIndex:indexPath.row];

        NSString *test = theCellData.ContentDescription;
        cell.textLabel.text = test;

        return cell;
    }
}

我有 tableView 委托和数据源,但在检查数组中的计数时仍然没有显示任何内容,它显示了其中的项目,但没有在 tableview 中显示数据我为 else 显示的数据表不起作用

4

2 回答 2

0

什么返回您的方法 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section?你能显示你的代码吗?

还要检查您是否为所有表设置了委托和数据源。

对不起,我发布了这个类似的答案。我没有发表评论的声誉。

于 2013-08-28T10:16:04.063 回答
0

检查单元格标识符..您是否为表格单元格提供了任何自定义单元格标识符?在这里你提到它

NSString *CellIdentifier = @"Cell";
于 2013-08-28T11:09:59.320 回答