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

No Desired Index Path #96

Open
brytonmoeller opened this issue Feb 13, 2016 · 2 comments
Open

No Desired Index Path #96

brytonmoeller opened this issue Feb 13, 2016 · 2 comments

Comments

@brytonmoeller
Copy link

I have an all exceptions breakpoint enabled. The program stops in SwiftPhotoGallery.swift here:

override public func viewDidLayoutSubviews() {
        let desiredIndexPath = NSIndexPath(forItem: pageBeforeRotation, inSection: 0)

        if pageBeforeRotation > 0 {
            scrollToImage(pageBeforeRotation, animated: false)
        }

        imageCollectionView.reloadItemsAtIndexPaths([desiredIndexPath])

        if let currentCell = imageCollectionView.cellForItemAtIndexPath(desiredIndexPath) as? SwiftPhotoGalleryCell {
            currentCell.configureForNewImage()
        }

    }

We get this in the output:
*** Assertion failure in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UICollectionView.m:4324

DesiredIndexPath has "0 values".

When I turn off the exceptions breakpoint and press the continue button in the debugger, it crashes with this message:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (5) must be equal to the number of items contained in that section before the update (4), plus or minus the number of items inserted or deleted from that section (1 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).' *** First throw call stack: (0x183591900 0x182bfff80 0x1835917d0 0x183f0499c 0x188aaf1f8 0x188467588 0x1005aa634 0x1005aa7bc 0x18827f7b8 0x185c8eb2c 0x185c89738 0x185c895f8 0x185c88c94 0x185c889dc 0x188275c78 0x183548588 0x18354632c 0x18354675c 0x183475680 0x184984088 0x1882ecd90 0x100100b60 0x1830168b8) libc++abi.dylib: terminating with uncaught exception of type NSException

@brytonmoeller
Copy link
Author

Any help you could give would be greatly appreciated, especially as we are a team of student programmers trying to meet a deadline.

@viewDidAppear
Copy link

This has nothing to do with Haneke, it has everything to do with you not properly understanding the workings of UICollectionView and its Data Source.

Try making a question on Stack Overflow.

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

2 participants