ios - Collection View Error : request for number of items before section 7 when there are only 1 sections in the collection view -


i'm using collection view , i'm trying switch 1 collection view layout using:

[self.collectionview setcollectionviewlayout:newlayout animated:animated]; 

which seems work fine , new layout items in.

however, when switch new layout, want show items in particular section. suppose first question is, have pointers correct way achieve this?

the way i'm doing remove items array used collection view. this, i'm using

- (void)removeobjectsinarray:(nsarray *)otherarray 

to remove items model, , then

- (void)deletesections:(nsindexset *)sections 

to remove sections collection view.

on doing this, following error

*** assertion failure in -[uicollectionviewdata numberofitemsbeforesection:],   /sourcecache/uikit_sim/uikit-2380.17/uicollectionviewdata.m:415 2013-05-03 07:35:18.543 clients[69375:c07] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'request number of items before section 7 when there 1 sections in collection view' 

does have thoughts on why specific error. searching i've done seems point similar errors, not exact one. thoughts has appreciated.

thanks.

--- update

i should have mentioned i'm doing inside gesture recogniser, seems important. i've extracted code , added button run too. running button seems work (except animations off), doing gesture still gives me error.

the code follows:

[self.collectionview performbatchupdates:^{     nsstring *selectedmarketsector = [[[[_allmarketsectors objectatindex:stackslayout.pinchedstackindex] clients] objectatindex:0] clientmarketsector];     nsmutablearray* removeobjects = [[nsmutablearray alloc] init];     nsmutableindexset *removesections = [[nsmutableindexset alloc] init];     (tbmarketsector* sector in _marketsectors) {         if (![[[[sector clients] objectatindex:0] clientmarketsector ] isequaltostring:selectedmarketsector]) {             [removeobjects addobject:sector];             [removesections addindex:[_marketsectors indexofobject:sector]];         }     }     [_marketsectors removeobjectsinarray:removeobjects];     [self.collectionview deletesections:removesections]; } completion:^(bool finished) {     [self setlayoutstyle:tblayoutgrid animated:yes]; }]; 

--- update 2

i discovered first custom layout still trying layout items after i'd removed them collection view , model. first had stop layout setting pinched stack index -1:

[stackslayout setpinchedstackindex:-1]; 

so code in stacks layout stop trying layout items:

- (void)setpinchedstackindex:(nsinteger)pinchedstackindex {     _pinchedstackindex = pinchedstackindex;     bool waspinching = self.ispinching;     [self setpinching:pinchedstackindex >= 0];     if (self.ispinching != waspinching)     {         if (self.ispinching)             self.gridlayout = [[gridlayout alloc] init];         else             self.gridlayout = nil;     }     [self invalidatelayout]; } 

this sample code from mark pospesel

so code looks follows:

[self.collectionview performbatchupdates:^{     nsstring *selectedmarketsector = [[[[_marketsectors  objectatindex:stackslayout.pinchedstackindex] clients] objectatindex:0] clientmarketsector];     [stackslayout setpinchedstackindex:-1];     nsmutablearray* removeobjects = [[nsmutablearray alloc] init];     nsmutableindexset *removesections = [[nsmutableindexset alloc] init];     (tbmarketsector* sector in _marketsectors) {         if (![[[[sector clients] objectatindex:0] clientmarketsector ] isequaltostring:selectedmarketsector]) {             [removeobjects addobject:sector];             [removesections addindex:[_marketsectors indexofobject:sector]];         }     }     [_marketsectors removeobjectsinarray:removeobjects];     [self.collectionview deletesections:removesections]; } completion:^(bool finished) {     [self setlayoutstyle:tblayoutgrid animated:yes]; }]; 

that gives me separate problem guess should log separately, essentially, when pinch stack out, stack layout lines items nicely in temporary grid, when switches layouts grid layout momentarily bounce stack , out grid again.

i suppose goes original question is, correct way switch 1 layout next -- photos app on ipad seems switch out view completely, doesn't seem 'jump' 1 layout next, though there pinch gesture going on example.

thanks additional information can provide.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -