0

現在、カスタム UITableViewCell を使用してテーブルビューを作成しています。これまで何度もやったことがありますが、何らかの理由でセルが正しく表示されません。また、上にスクロールすると、テキスト ラベルが消え始めますが、この時点では理由がわかりません。cellForRowAtIndexPath メソッドは次のとおりです。

- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"Row: %i Section: %i", indexPath.row , indexPath.section);
HollerCommentCell *cell = (HollerCommentCell *)[table dequeueReusableCellWithIdentifier:@"HollerCommentCell"];
if( !cell )
{
    //Initialize a new cell
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"HollerCommentCell" owner:nil options:nil];
    for( id currentObject in topLevelObjects )
    {
        if([currentObject isKindOfClass:[HollerCommentCell class]]){
            cell = (HollerCommentCell*)currentObject;
            break;
        }
    }
}
[[cell name]setText:@"Nick"];
[[cell commentText]setText:@"Hello"];
return cell;
}

また、ここに私の numberOfRowsInSection メソッドのコピーがあります:

- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section{
    return ( section == 0 ) ? 5 : 0;
}

これがどのように機能するかのスクリーンショットです:

ここに画像の説明を入力

今何が起こっているのかわかりません。考え?

4

1 に答える 1

0

クリッピングがオフになっていて、commentTextラベルが44ポイント低すぎます。その結果、commentTextは、設定するセルのすぐ下の行に表示されます。

セル内のNSLogビューを表示して、それらのフレームがどこに配置されているかを確認する必要があるかもしれません。

于 2012-07-25T00:33:19.027 に答える