1

私はデータを表示するためにtableViewを使用しているiPadアプリを持っていますが、問題は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デリゲートとdataSourceがありますが、配列のチェックカウント中に何も表示されませんが、その中に項目が表示されますが、テーブルビューにデータが表示されませんelseテーブルに表示しているデータが機能していません

4

2 に答える 2

0

セル識別子を確認してください..テーブルセルにカスタムセル識別子を指定しましたか? ここであなたはそれを次のように言及しています

NSString *CellIdentifier = @"Cell";
于 2013-08-28T11:09:59.320 に答える
0

あなたのメソッドを返すもの - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section? コードを表示できますか?

また、すべてのテーブルにデリゲートとデータソースを設定していることを確認してください。

このような回答を投稿してすみません。コメントに投稿するという評判はありません。

于 2013-08-28T10:16:04.063 に答える