ios – forestall cell stacking in UIcollectionView

Spread the love

I have been engaged on a set recreation utilizing apple maps in Goal C. Every merchandise you acquire seems in a uicollectionview. it really works completely wonderful till you get round 15 or so and have to start out scrolling down the view, then I get this bizarre stacking impact seen within the image. The kanohi discovered variable is working appropriately and there are 21 cells there for 21 gadgets.
Right here is my code (or at the least the vital bits):

- (void)viewDidLoad {
    [super viewDidLoad];
    maskArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"PlayerMasks"]; //get the gamers masks from the consumer defaults and make an array of them
    _maskGrid.delegate = self;
    _maskGrid.dataSource = self;


- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
    CollectionViewCell *cell3 = [_maskGrid dequeueReusableCellWithReuseIdentifier:@"cell3" forIndexPath:indexPath];
    return cell3;

- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)part {
    return maskArray.rely;

- (CGSize)collectionView:(UICollectionView *)collectionView format:   (UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(100, 100);

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ //faucet brings up delete dialog
    //NSLog(@"Tapped %d", (int)indexPath.row);
    selectedMaskArray = maskArray[indexPath.row]; //assign the brand new masks to a brief holding cell
    for (int i = 0; i <= (imagesInCollection.rely -1); i++)
        UIImage *tempImage = imagesInCollection[i]; //some technical wizardry to get the right masks and color displaying within the particular person masks show display screen
        //NSLog(@"A: %@", maskName);
        //NSLog(@"B: %@", tempImage.accessibilityIdentifier);
        if([tempImage.accessibilityIdentifier isEqualToString: selectedMaskArray[0]] ){
            outPutMask = tempImage;
    [self performSegueWithIdentifier:@"selectedMask" sender:self];

Anybody know find out how to cease this taking place? (Goal C solutions please, Swift is a little bit of a ache to translate to Obj-C typically)

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *