現在、カスタム 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;
}
これがどのように機能するかのスクリーンショットです:
今何が起こっているのかわかりません。考え?