ios - UICollectionView setting the last cell a section -


i'm working on carousel view works uicollection has form:

[cell1][cell2][cell3] ... [cell n][ + ] 

so uicollection has 1 section.

each cell has content except last one. last cell (n+1) have plus button inside allows user insert new cell in carousel.

i wrote code datasource method cellforitematindexpath know if cell @ current index path last cell:

if ([indexpath section] == sectionsamount - 1 && [indexpath row] == rowsamount - 1) {     formationcollectionviewcell * cell = [collectionview dequeuereusablecellwithreuseidentifier:@"cellformation" forindexpath:indexpath];     return cell. } 

the last cell of carousel okay, when scroll horizontally in carousel, the last cell generated @ index of carousel, , replaces other cells during scroll. think it's problem on reusable cell. can me please?

this want:

[cell1][cell2][cell3] ... [cell n][ + ] 

after init carousel have that:

[cell1][cell2][cell3] ... [cell n][ + ] 

so it's okay, when scroll in carousel have bug:

[cell1][ + ][ + ] ... [cell n][ + ] 

the last cell cloned @ positions.

you should override prepareforreuse method on cell subclass, , configuration cleanup there, resetting ui , cell states.

docs reference

update

does [ + ] cell uses same class [cell n] cells? if does, not clearing state before reusing (and thus, should clear on prepareforreuse method). if are, may using same cell identifier both.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -