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

Bug when deleting non-last photo. Another last photo appears beyond the last page of the scrollView_. #44

Open
hlung opened this issue May 20, 2012 · 0 comments

Comments

@hlung
Copy link

hlung commented May 20, 2012

Bug when deleting non-last photo. Another last photo appears beyond the last page of the scrollView_, though you cannot scroll to it. And sometimes next photo appear twice after delete.

Here are my fixes. (2 places, marked with // *** hlung: BUG FIX: )

  • (void)setCurrentIndex:(NSInteger)newIndex
    {
    currentIndex_ = newIndex;

    // *** hlung: BUG FIX: after delete, next photo appear twice, unload the second one
    [self unloadPhoto:currentIndex_ + 1];
    // ***

    [self loadPhoto:currentIndex_];
    [self loadPhoto:currentIndex_ + 1];
    [self loadPhoto:currentIndex_ - 1];
    [self unloadPhoto:currentIndex_ + 2];
    [self unloadPhoto:currentIndex_ - 2];

    [self setTitleWithCurrentPhotoIndex];
    [self toggleNavButtons];
    }

  • (void)deleteCurrentPhoto
    {
    if (dataSource_) {
    // TODO: Animate the deletion of the current photo.

    NSInteger photoIndexToDelete = currentIndex_;
    [self unloadPhoto:photoIndexToDelete];

    // *** hlung: BUG FIX: remove the last photoView_ before decrementing photoCount_
    if (photoCount_-1 > 0) [self unloadPhoto:photoCount_-1];
    // ***

    [dataSource_ deleteImageAtIndex:photoIndexToDelete];

    photoCount_ -= 1;
    if (photoCount_ == 0) {
    [self showChrome];
    [[self navigationController] popViewControllerAnimated:YES];
    } else {
    NSInteger nextIndex = photoIndexToDelete;
    if (nextIndex == photoCount_) {
    nextIndex -= 1;
    }
    [self setCurrentIndex:nextIndex];
    [self setScrollViewContentSize];
    }
    }
    }

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

1 participant