我将数据插入到表格视图中,如下所示。还有如果有超过6个然后应用程序崩溃的5至6元没问题,并显示错误:为什么我在将第六个元素插入tableview的时候出现NSRangeException?
"Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 11 beyond bounds [0 .. 10]' "
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
return [ProductArray count];
}
- (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] autorelease];
}
NSDictionary *aDict = [ProductArray objectAtIndex:indexPath.row];
cell.textLabel.text= [aDict objectForKey:@"ProductName"];
return cell;
}
你能后与您插入新的数据的代码? – 2011-04-21 09:13:33
它坠毁超过6层的元件,因为这是当表是可滚动的。 UITableView在滚动时加载行。 – samwize 2011-04-21 10:01:55