Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:], /SourceCache/UIKit/UIKit-2380.17/UITableViewRowData.m:400
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:'Failed to allocate data stores for 997008923 rows in section 0. Consider using fewer rows'
我的代碼爲什麼聲明失敗 - [UISectionRowData refreshWithSection:tableView:tableViewRowData:]?
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [appDelegate.purchaseArray 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];
}
return cell;
}
-(void)viewWillAppear:(BOOL)animated
{
[cartTbl reloadData];
}
我沒有得到什麼這是問題嗎?
不幸的是,當您創建/修改它們時,Apple不會仔細檢查許多UI對象上的參數,並且在檢測到不一致時選擇不使用信息性錯誤消息。但基本上這個斷言意味着你已經在你的表格控件中隱藏了一些東西。首先確保你已經設置了'delegate'和'dataSource'。 – 2013-03-20 12:04:53
但仔細檢查後,請參閱「無法爲第0部分中的997008923行分配數據存儲。請考慮使用更少的行」。我懷疑purchaseArray.count實際上有很多行,但不知何故該值必須被忽略。在numberOfRowsInSection中添加一個NSLog以記錄返回值。 – 2013-03-20 12:09:02
它在模擬器中運行正常,但不能在設備上運行。 – user2071201 2013-03-20 12:29:34