0
我正在研究一个项目,我需要在表格中填充单元格并让它们显示在屏幕上。我有表格显示,但现在数据显示在单元格中。我试过使用断点,发现这个方法永远不会被调用。它之前的方法(numberOfRowsInSection)确实被调用。有什么建议么?cellForRowAtIndexPath不被调用?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Resident *aResident = (Resident *)[appDelegate.residents objectAtIndex:indexPath.row];
cell.textLabel.text = aResident.name;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
既然他说numberOfRowsInSection被调用,那些似乎设置.... – Mario 2012-04-25 20:32:05
dint注意到..我的坏..所以它应该是,numberOfRows/numberOfSections返回0 .. – Roshit 2012-04-25 20:48:28
你是对的,计数是归零。现在我只需要弄清楚为什么数组会返回零计数。 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)部分NSLog(@“Count =%i”,[appDelegate.residents count]); return [appDelegate.residents count]; – 2012-04-26 15:53:31