我有我的ViewController
它n
數量的部分在我的第一部始終顯示我心願產品(僅基於顯示收藏在SettingsController
啓用選項)每次UITableView
當我一個產品添加到我的願望清單在我的DetailViewController
我觸發NSNotificatiion
到我的ViewController
它將取回願望清單記錄。如何刷新特定部分?
我numberOfRowsInSection:
總是返回1
,因爲它是一個UITableView + UICollectionView
組合產生水平+ Vertial滾動。
所以,我重裝我的部分像下面這樣,
if (isWishListSectionReloadRequires) {
NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
[NSIndexPath indexPathForRow:0 inSection:0],
nil];
NSArray *insertIndexPaths = [NSArray arrayWithObjects:
[NSIndexPath indexPathForRow:0 inSection:0],
nil];
[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationNone];
[tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
} else {
[tableView reloadData];
}
但是,我面臨崩潰之下,
斷言失敗 - [UITableView的_endCellAnimationsWithContext:]/SourceCache /UIKit_Sim/UIKit-2380.17/UITableView.m:1054 2016-11-04 04:25:15.921估計[9025:c07] ***因未捕獲異常'NSInternalInconsistencyException'而終止應用,原因:'無效更新:無效數量部分。更新後表格視圖中包含的節數(10)必須等於更新前表格視圖中包含的節數(10),加上或減去插入或刪除的節數(插入1次,1次刪除)
誰能告訴我可能是什麼原因?任何想法將不勝感激!
您是否相應地更新了數據源?我的意思是在一個部分的行數等? – KrishnaCA
@KrishnaChaitanyaAmjuri我如何手動更新數據源? – Praveenkumar
嘗試 - (void)reloadSections:(NSIndexSet *)節withRowAnimation:(UITableViewRowAnimation)動畫,而不是刪除和插入。 – Sealos