我有一個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