ios - UICollectionView insert items transitions not working as expected -
in uicollectionview i'm inserting items retrieve data server. have custom layout file , i'm using initiallayoutattributesforappearingitematindexpath
method define how cells must appear they're inserted. problem have transition defined in initiallayoutattributesforappearingitematindexpath
not working cells not in first screen space.
for example lets have 20 items in collection view. 10 of them can fit first screen , other 10 below have scroll , view (typical scenario). transitions first 10 works fine* scroll down can see items 11-20 wont animate , still remain @ initial position.
as simple example lets offset frame 50px left. items 11-20 scroll down remain @ -50 offset frame , wont return normal place. can guide me on how fix ?
here how insert data
nsmutablearray *indexarr = [nsmutablearray array]; (int i=0; i<weakself.data.count; i++) { [indexarr addobject:[nsindexpath indexpathforitem:i insection:0]]; } [weakself.collectionview insertitemsatindexpaths:indexarr];
here how set layout method appearing items
- (uicollectionviewlayoutattributes *)initiallayoutattributesforappearingitematindexpath:(nsindexpath *)itemindexpath { uicollectionviewlayoutattributes *attributes = self.itemattributes[itemindexpath.item]; attributes.frame = cgrectoffset(attributes.frame, -50, 0); return attributes; }
thanks
Comments
Post a Comment