Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange disappearing items when scrolls

Presets,

i have collectionViewFlowLayout subclass with

- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
    return YES;
   }

- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *arr = [super layoutAttributesForElementsInRect:rect];
    BBLog(@"ARRA:%@", arr);
    for (UICollectionViewLayoutAttributes *attr in arr) {
        if (CGAffineTransformIsIdentity(attr.transform)) {
            attr.transform = CGAffineTransformMakeRotation((CGFloat)M_PI);
        }
    }

    return arr;
}

CollectionView rotate to upside down scroll with

 self.collectionView.transform = CGAffineTransformMakeRotation((CGFloat)M_PI);

But even if jus use native collectionViewFlowLayout without subclassing, a git this error

Problem

I have two messages and more in chat, but when scroll at bottom (top normally) disappear second item.

layoutAttributesForElementsInRect for given rect return two attributes for two indexPaths 0-0 and 0-1, but delegate method

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

called only for indexPath 0-0

Here images

TopScroll enter image description here

UPDATE So i found WHY it's happen - this line code

attr.transform = CGAffineTransformMakeRotation((CGFloat)M_PI);

Look if remove transform

enter image description here

like image 356
Dmitry Nelepov Avatar asked Jan 19 '16 13:01

Dmitry Nelepov


People also ask

Why does an object disappear when you aren't looking?

You think the object disappears when you aren’t looking. What could be happening is that the universe decoheres that you’re in into 2 branches - one with you and the other with the object. If and when the object returns, what is happening is a rejoining of the 2 branches into on

Do poltergeists cause disappearing objects?

When disappearing object phenomena (DOP) occur, a lot of people blame a poltergeist, if only half seriously. A poltergeist is usually defined as a mischievous or noisy spirit. Poltergeist activity often includes unexplained noises, music, smells, and movement of objects.

What are the different types of disappearances?

Disappearing Object Phenomenon 1 Absentmindedness. When examining such occurrences as DOP, you must first consider the most ordinary possibility: that the person simply misplaced the object or forgot where she put it. 2 The Borrower. ... 3 Poltergeist. ... 4 Temporary Invisibility. ... 5 Dimensional Shift. ...

Did you ever drop something and it completely disappears immediately?

I have been psychic since childhood, so I have learned to live with this type of occurrence. Just ma Have you ever dropped something and it completely disappears immediately? yes actually. It was a pillow. It fell off my bed when I was waking up. And it literally disappeared. I have no idea where it went. it bothers me to think about it actually.


1 Answers

I am not entirely sure, but I think that, when You are subclassing the UICollectionViewFlowLayout, You are not supposed to modify the attributes directly, but to make a copy of the attributes, modify it instead and return it.

Short explanation of the top statement : You will have to subclass the UICollectionViewFlowDelegate ( the parent of UICollectionViewDelegateFlowLayout ) and than make your own attributes and modify them as You wish, but this will require of to implement a lot more custom logic.

Also look if You are getting any errors or warnings in the console.

Check out this question : Warning: UICollectionViewFlowLayout has cached frame mismatch for index path 'abc'

Hope that I was at least a little helpful.

like image 106
Georgi Boyadzhiev Avatar answered Sep 20 '22 04:09

Georgi Boyadzhiev