ios - How do i refresh the particular Section? -
i have uitableview
on viewcontroller
has n
number of sections first section displays wishlist products (only based on show wishlist option enabled in settingscontroller
) every time when add product wishlist on detailviewcontroller
i'm triggering nsnotificatiion
viewcontroller
fetch wishlist records.
my numberofrowsinsection:
returns 1
because, uitableview + uicollectionview
combination produce horizontal + vertial scrolling.
so, i'm reloading section below way,
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]; }
but, i'm facing below crash,
assertion failure in -[uitableview _endcellanimationswithcontext:], /sourcecache/uikit_sim/uikit-2380.17/uitableview.m:1054 2016-11-04 04:25:15.921 estimation[9025:c07] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid update: invalid number of sections. number of sections contained in table view after update (10) must equal number of sections contained in table view before update (10), plus or minus number of sections inserted or deleted (1 inserted, 1 deleted)
can tell me reason? idea appreciated!!
you use uitableview's reloadsections method instead.
objective c
nsrange range = nsmakerange(0, 1); nsindexset *section = [nsindexset indexsetwithindexesinrange:range]; [self.tableview reloadsections:section withrowanimation:uitableviewrowanimationnone];
swift
tableview.reloadsections(nsindexset(index: 2), withrowanimation: .none)
Comments
Post a Comment