ios - UICollectionView inside a container view -


desc:

i have view controller holds collection view 7 cells inside of it. when display controller, works fine , displays (controller a). on controller (controller b) have container view embeds controller a, collection view.

the problem:

when running app , going controller b (that embeds controller a), controller a's sub views except of collection view. in case, instead of seeing 7 cells see 6 , after tapping on 1 of cells, last cell appears in cells row , looks (?!). collection view being redrawn , cant find reason or how fix it.

any appreciated.

edit

that flow layout, call viewdidload:

-(void) setflowlayout {     bool isiphone = (ui_user_interface_idiom() != uiuserinterfaceidiompad);     float basewidth = [[uiscreen mainscreen] bounds].size.width;     int width;      width = floor(basewidth / 7.0);     float space = basewidth - (width * 7.0f);     space /= 7.0;      uicollectionviewflowlayout * flow = [[uicollectionviewflowlayout alloc] init];      if(isiphone) {         flow.itemsize = cgsizemake(width, kcellheight);     }     else{         flow.itemsize = cgsizemake(width, kcellsizeipad);     }      flow.minimuminteritemspacing = space;     flow.headerreferencesize = cgsizemake(_collectiondays.frame.size.width, kspacing);     flow.footerreferencesize = cgsizezero;     flow.scrolldirection = uicollectionviewscrolldirectionvertical;      [_collectiondays setcollectionviewlayout:flow]; } 

i use place cells in middle of collection view:

- (uiedgeinsets)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout *)collectionviewlayout insetforsectionatindex:(nsinteger)section{     cgfloat cellspacing = ((uicollectionviewflowlayout *) collectionviewlayout).minimuminteritemspacing;     cgfloat cellwidth = ((uicollectionviewflowlayout *) collectionviewlayout).itemsize.width;     nsinteger cellcount = [collectionview numberofitemsinsection:section];     cgfloat inset = (collectionview.bounds.size.width - (cellcount * (cellwidth + cellspacing))) * 0.5;     inset = max(inset, 0.0);      return uiedgeinsetsmake(0.0, inset, 0.0, inset); } 

this bad part, not 7 cells there

thats how should like

so no answer far, found way fix it. kept on trying solve it, , think has container resize while being drawn.

i fixed using call collection view's layoutifneeded parent view controller, in viewdidlayoutsubviews.

so if comes across it, 1 way of fixing it.

would love hear better way\explanation.

-(void)viewdidlayoutsubviews {     [super viewdidlayoutsubviews];      [_collectiondays layoutifneeded];     [_collectiondays reloaddata]; } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -