我將數據插入到表格視圖中,如下所示。還有如果有超過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