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

NSInternalInconsistencyException - Cant have ChartLegends embedded in a collection view #3

Closed
HexBlit opened this issue Jul 3, 2017 · 6 comments

Comments

@HexBlit
Copy link

HexBlit commented Jul 3, 2017

I get a couple different errors based on trying to get this working inside a collection view that i am using as a carousel of cards of charts.

if I try to use the default setLegends in the example I get this:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier TextLabelChartLegendCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

If I try to use a custom cell I get this:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier DemandByStackedCardCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

@ivnsch
Copy link
Owner

ivnsch commented Jul 4, 2017

Thanks for reporting. I'll check as soon as I have time... probably the coming weekend. In the meantime, feel free to investigate it, the library should be fairly simple to debug...

@Boxleitner
Copy link

I get the same Problems with using the Legends within an UIScrollView. Is there a solution yet?

@ivnsch
Copy link
Owner

ivnsch commented Aug 17, 2017

Evidently not, but as mentioned before feel free to give it a look, the library is quite small and should be understandable... the legends are a collection view so there shouldn't be anything particularly mysterious going on. otherwise I'll try to do this soon, sorry, very busy these days.

@langhisc
Copy link

langhisc commented Oct 9, 2017

ChartLegendsView.swift, line 170:

fileprivate func register(cellType: CellType) {
        let frameworkBundleId = "com.schuetz.ChartLegends"
        if Bundle.main.path(forResource: cellType.reuseIdentifier, ofType: "nib") != nil {
            collectionView?.register(UINib(nibName: cellType.reuseIdentifier, bundle: nil), forCellWithReuseIdentifier: cellType.reuseIdentifier)
        } else if Bundle(identifier: frameworkBundleId)?.path(forResource: cellType.reuseIdentifier, ofType: "nib") != nil {
            collectionView?.register(UINib(nibName: cellType.reuseIdentifier, bundle: Bundle(identifier: frameworkBundleId)), forCellWithReuseIdentifier: cellType.reuseIdentifier)
        }
    }

These NIB files are not actually included in the ChartLegends bundle, so the if conditions always fail, and collectionView.register() is never called. This creates a crash with 100% frequency and renders the basic ChartLegends workflow unusable.
The missing NIB files are present in the example project's copy of the ChartLegends source. I tried manually copying them over to my project. Then, I got a different crash — something about a class not being compliant for a selector.

@ivnsch
Copy link
Owner

ivnsch commented Jan 22, 2018

Well, I don't have time, but I'm quick at merging pull requests :)

@ivnsch
Copy link
Owner

ivnsch commented Jan 22, 2018

Fixed in 0.0.5

@ivnsch ivnsch closed this as completed Jan 22, 2018
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

4 participants