ios - reloadData not working for UICollectionView in iOS7 -
so have search method "searchtablelist" , after result want, want reload uicollectionview
- (void)searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext { // nslog(@"text change - %d",issearching); //remove objects first. [filteredcontentlist removeallobjects]; if([searchtext length] != 0) { issearching = yes; [self searchtablelist]; } else { issearching = no; } [self.collectionview reloaddata]; } however after "[self.collectionview reloaddata]" nothing happens !
after using this, crashes time !
[self.collectionview reloaditemsatindexpaths:[self.collectionview indexpathsforvisibleitems]]; [self.collectionview reloaddata]; what can do, alot!!! :d
error message is:
2014-04-16 18:24:35.684 sampleproject1[59602:60b] item width must less width of uicollectionview minus section insets left , right values. 2014-04-16 18:24:37.709 sampleproject1[59602:60b] *** assertion failure in -[uicollectionview _enditemanimations], /sourcecache/uikit_sim/uikit-2935.137/uicollectionview.m:3688 2014-04-16 18:24:37.713 sampleproject1[59602:60b] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'attempt insert item 0 section 0, there 0 items in section 0 after update' fixed it:
basically returning count of unused array had lenght of 0 instead of relevant array !
so had change this:
if (issearching) { return [searchresult count]; } else { return [self.tracks count]; } to: if (issearching) {
return [filteredcontentlist count]; } else { return [self.tracks count]; } then after removed reloaddata jargons , replaced with:
[self.collectionview reloaddata]; thanks alot guys !!
- after writing reloaditemsatindexpaths no need of writing again reloaddata.
- reload respective collection view row using main thread.
code snippet:
[[nsoperationqueue mainqueue] addoperationwithblock:^{ // reload respective collection view row using main thread. [self.collectionview reloaditemsatindexpaths:[self.collectionview indexpathsforvisibleitems]]; }];
Comments
Post a Comment