我有一个UIView,并且我已经放置了一个tableview,tableview使用从NSArray中提供数据的自定义单元格。一些奇怪的事情发生在我最多的时候,我只能让表格显示2个单元格,即使有10个单元格,所有10个单元格都已填充。UITableView与自定义单元格
我有一个不同的笔尖排列相同的方式,它的作品完美。
正在发生的事情的截图(5是10个单元格中的第5个,所有这些单元格都填充了数据)。
http://img692.imageshack.us/img692/1465/screenshot20100708at215.jpg
-(UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"ISB points cellForRowAtIndexPath start");
NSLog(@"Elements in array = %d",[self.listData count]);
//
static NSString *cellID = @"PointsCellIdentifier";
PointsCustomCell *cell = [tblView dequeueReusableCellWithIdentifier:cellID];
if(cell == nil)
{
NSArray *nibObjects = [[NSBundle mainBundle]loadNibNamed:@"PointsCustomCell" owner:nil options:nil];
for(id currentObject in nibObjects)
{
NSLog(@"nibObjects count = %d", [nibObjects count]);
if([currentObject isKindOfClass:[PointsCustomCell class]])
{
cell = (PointsCustomCell *)currentObject;
}// if
}// for
}// if
if(indexPath.row < [listData count])
{
RiderPointsData *riderPts = (RiderPointsData *)[listData objectAtIndex:indexPath.row];
cell.posLabel.text = riderPts.pos;
cell.nameLabel.text = riderPts.name;
cell.pointsLabel.text = riderPts.points;
cell.winsLabel.text = riderPts.wins;
//[riderPts release];
}
NSLog(@"ISB points cellForRowAtIndexPath end");
return cell;
}
发布您用于TableView数据源代理的代码 – Avalanchis 2010-07-08 21:18:41
而不是在评论中发布代码,在没有格式的情况下,使用适当的代码编辑您的问题。 – 2010-07-08 21:51:01
哪里是你的[tableView:numberOfRowsInSection:](http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITableViewDataSource/tableView: numberOfRowsInSection :)方法?什么是*它*返回? – progrmr 2010-07-08 22:45:20