我目前正在用自定义UITableViewCell构建tableview。我之前做过这么多次,但由于某些原因,这些细胞并没有显示正确。当我滚动文本标签开始消失,在这一点上,我不知道为什么。这里的的cellForRowAtIndexPath方法:自定义UITableViewCell标签消失
- (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;
}
这里是它是如何工作的截图:
不知道这是怎么回事现在。思考?
所以为了让这一切顺利 - 当你第一次看到这个视角时,一切看起来都很完美。但是你不能真的向右滚动,你只有5个单元格?细胞数量是否改变?如果它确实重新加载表格后? – 2012-07-25 00:48:25