1

我有一个tableview带有 6 个单元格的view. 总共有10个细胞。当我尝试向下滚动时,模拟器会自动终止并出现异常。有人可以帮忙吗?

关于这个问题,我在网上浏览了很多次,但都没有成功。

我得到以下异常:

异常'NSRangeException',原因:' * -[NSMutableArray objectAtIndex:]:索引 10 超出范围 [0 .. 1]'

这是我的委托方法代码:

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"cell"]; 
    if( cell == nil ) { 
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
        cell.textLabel.text = [tableData objectAtIndex:indexPath.row]; 
    } 
    return cell; 
}
4

1 回答 1

0

检查你的阵列。它有 9 个值。你的表试图在你的数组中获得第 10 个索引。

于 2013-06-24T12:45:42.650 回答