我有一個tableView與一些部分,其中都有一個頁腳,然後我有一個TableViewFooter Tableview本身。爲什麼我得到一個assert錯誤當試圖刪除一個tableview中的一段ios
如果我向下滾動到我的tableview的底部,並在最後一節以上的任何部分刪除最後一項(因此總共刪去該條)(倒數第二及以上)它給了我這個錯誤
2014-02-21 13:19:55.066 xxxx[5436:60b] *** Assertion failure in -[UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:], /SourceCache/UIKit/UIKit-2903.23/UITableViewSupport.m:2661
Uncaught exception: Cell animation stop fraction must be greater than start fraction
在endUpdates
這是我的代碼
[self.tableView beginUpdates];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
if(indexPath != nil){
TableSection * sec = [self.sections objectAtIndex:indexPath.section];
NSMutableDictionary *dic =[sec.items objectAtIndex:indexPath.row];
Product* product = [dic valueForKey:PRODUCT];
//removing the item in the section
[sec.items removeObject:dic];
//deleting item from products
NSMutableArray *temp = [NSMutableArray array];
for (Product *p in self.dataCon.listPersister.products) {
if ([p.product.objId isEqualToString: product.product.objId]) {
[temp addObject:p];
}
}
for (Product *p in temp) {
[self.dataCon.listPersister.products removeObject:p];
}
//if it was the last object in section, delete the section else just delete the single row
if(sec.items.count == 0)
{
[self.sections removeObject:sec];
[self.footers removeObjectAtIndex:indexPath.section];
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationFade];
} else
{
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
USFooterView *footer = [self.footers objectAtIndex:indexPath.section];
footer.totalLabel.text = [self.dataCon.listPersister getTotalForShopId:sec.title];
self.footerView.totalLabel.text = [self.dataCon.listPersister getTotalForAllProducts];
}
}
[self.tableView endUpdates];
我有同樣的代碼前面,只是無需頁腳我的tableView和桌子部分,在那裏它瓦特所以我認爲他們可能會成爲問題,但我不完全確定這是它行事的原因。
我已經看到了這個帖子
UITableView tableFooterView may cause crash?
而且它鏈接到職位,但沒有幫助我。
任何幫助表示讚賞:)
你試過這個:http://stackoverflow.com/a/19861743/1179863? –
我剛剛嘗試了一些我以前沒有嘗試過的建議,但是我之前已經看到過這個帖子,但沒有一個答案可以解決我的問題,不過謝謝:) – Hafax