mercredi 20 juillet 2016

Xcode - [UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (7) beyond bounds (0) for section (0).'

I've just implemented the AGPhotoBrowser class into my Xcode project and I'm getting the error of:

Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (7) beyond bounds (0) for section (0).'

The code where the crash happens is here:

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (!self.currentWindow.hidden && !_changingOrientation) {
        [self.overlayView resetOverlayView];

        CGPoint targetContentOffset = scrollView.contentOffset;

        UITableView *tv = (UITableView*)scrollView;
        NSIndexPath *indexPathOfTopRowAfterScrolling = [tv indexPathForRowAtPoint:targetContentOffset];

        [self setupPhotoForIndex:indexPathOfTopRowAfterScrolling.row];
    }
}

The crash seems to happen as soon as I exit the ViewController where this is implemented? Could anyone help? Cheers, Declan

Aucun commentaire:

Enregistrer un commentaire