Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 photo disappears #7

Open
jesusgarza opened this issue Sep 26, 2012 · 5 comments
Open

1 photo disappears #7

jesusgarza opened this issue Sep 26, 2012 · 5 comments

Comments

@jesusgarza
Copy link

Modify TMDemoQuiltViewController to have only one cell:

const NSInteger kNumberOfCells = 1;

Run the demo project and scroll up the view until you completely hide the photo in the upper margin. It seems as if the photo doesn't come back down.

@suyangdong
Copy link

I also observe this question. Actually as long as the ALL of images of one column get scrolled out of the top of the view, they won't come back.
I try to trace, it looks like, the 'bottom' of that column won't change after that. However I 'guess' (since I don't understand the code completely) it might have something to do with the logic in the code below, wish someone could help since this situation is quite common. Thanks. (One can change all of the images' sizes to 1024 * 768 to reproduce such problem)

    while ((*top > 0) && [TMQuiltView isRect:[self rectForCellAtIndex:*top column:i] entirelyInOrBelowScrollView:self]) {
        if ([TMQuiltView isRect:[self rectForCellAtIndex:*top - 1 column:i] partiallyInScrollView:self]) {
            NSIndexPath *newIndexPath = [indexPaths objectAtIndex:*top - 1];
            TMQuiltViewCell* newCell = [self.dataSource quiltView:self cellAtIndexPath:newIndexPath];
            newCell.frame = [self rectForCellAtIndex:*top - 1 column:i];
            [indexPathToView setObject:newCell forKey:newIndexPath];
            [self addSubview:newCell];
        }
        (*top)--;
    }

@scottliu1234
Copy link

The cause of this problem is cell-reuse. The following code removes the cell from View when a cell leaves the visible rect, but in this case a new cell is not re-drawn when it bounces back into the frame:
for (NSIndexPath* indexPath in [indexPathToView allKeys]) {
TMQuiltViewCell *view = [indexPathToView objectForKey:indexPath];
if (![TMQuiltView isRect:view.frame partiallyInScrollView:self]) { // Rect intersection?
[indexPathToView removeObjectForKey:indexPath];
// Limit the size on the reuse pool
if ([[self reusableViewsWithReuseIdentifier:view.reuseIdentifier] count] < 10) {
[[self reusableViewsWithReuseIdentifier:view.reuseIdentifier] addObject:view];
}
[view removeFromSuperview];
// Only harvest once per call to make things smoother
//break;
}
}

A somewhat hacky fix would be only call that code when contentSize.height > frame.size.height, since cell reuse is unnecessary if the content size is smaller than view frame. But that does not address the root issue of not redrawing the cell upon the view bouncing back.

@pawartur
Copy link

pawartur commented Jan 4, 2013

I've just run at the same problem. Any progress on this?

pawartur pushed a commit to pawartur/TMQuiltView that referenced this issue Jan 4, 2013
… are pulled off when the quilt view bounces.
pawartur pushed a commit to pawartur/TMQuiltView that referenced this issue Jan 4, 2013
@wtuyp
Copy link

wtuyp commented Mar 23, 2013

Good Job,the problem has gone!Thank you!

@pigpigdaddy
Copy link

@pawartur good work, Thank U!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants