ios - UICollectionViewCell Not drawing cell on indexpath.row == 0 -
see image attached.
i'm using basic uiflowlayout subclass accompany view, no matter i've tried, decides doesn't need draw cell 0,
however if scroll down , up, draw properly.
it seems it's ios sdk bug, need investigate further. wondering if knows ideas try this.
this answer solve it:
uicollectionview flowlayout not wrapping cells correctly (ios)1
but case unique using uidynamicanimator calculate layout attributes.
so code went this:
-(nsarray *)layoutattributesforelementsinrect:(cgrect)rect { return [self.dynamicanimator itemsinrect:rect]; } -(uicollectionviewlayoutattributes *)layoutattributesforitematindexpath:(nsindexpath *)indexpath { return [self.dynamicanimator layoutattributesforcellatindexpath:indexpath]; } - (uicollectionviewlayoutattributes *)layoutattributesforsupplementaryviewofkind:(nsstring *)kind atindexpath:(nsindexpath *)indexpath { return [self.dynamicanimator layoutattributesforsupplementaryviewofkind: kind atindexpath:indexpath]; }
to this:
-(nsarray *)layoutattributesforelementsinrect:(cgrect)rect { nsarray *attributes = [super layoutattributesforelementsinrect:rect]; nsmutablearray *newattributes = [nsmutablearray arraywithcapacity:attributes.count]; (uicollectionviewlayoutattributes *attribute in attributes) { if ((attribute.frame.origin.x + attribute.frame.size.width <= self.collectionviewcontentsize.width) && (attribute.frame.origin.y + attribute.frame.size.height <= self.collectionviewcontentsize.height)) { [newattributes addobject:attribute]; } } return newattributes; } -(uicollectionviewlayoutattributes *)layoutattributesforitematindexpath:(nsindexpath *)indexpath { return [self.dynamicanimator layoutattributesforcellatindexpath:indexpath]; } - (uicollectionviewlayoutattributes *)layoutattributesforsupplementaryviewofkind:(nsstring *)kind atindexpath:(nsindexpath *)indexpath { return [self.dynamicanimator layoutattributesforsupplementaryviewofkind: kind atindexpath:indexpath]; }
and problem solved! it's plausable logic in code -(bool)shouldinvalidatelayoutforboundschange doing wrong, had checked , logic looked fine.
Comments
Post a Comment