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

iOS 18 dequeueReusableSupplementaryView throws NSInternalInconsistencyException #367

Open
ccompton-ip opened this issue Nov 6, 2024 · 0 comments

Comments

@ccompton-ip
Copy link

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <BSImagePicker.AssetLimitedHeaderView: 0x7f8f39d04580; baseClass = UICollectionReusableView; frame = (0 0; 0 0); alpha = 0; layer = <CALayer: 0x6000003c8fe0>>; Collection view: <UICollectionView: 0x7f8f37c66000; frame = (0 97.6667; 393 754.333); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000cb4c90>; backgroundColor = <UIDynamicSystemColor: 0x6000016d3080; name = systemBackgroundColor>; layer = <CALayer: 0x6000002e5300>; contentOffset: {0, 0}; contentSize: {393, 70.12109375}; adjustedContentInset: {0, 0, 34, 0}; layout: <UICollectionViewFlowLayout: 0x7f8f377eea60>; dataSource: <BSImagePicker.AssetsCollectionViewDataSource: 0x600002099720>>'

Exception is thrown from within

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
        if #available(iOS 14, *) {
            if
                PHPhotoLibrary.authorizationStatus(for: .readWrite) == .limited,
                let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: photoLimited, for: IndexPath(row: 0, section: section)) as? AssetLimitedHeaderView {

                return CGSize(width: collectionView.frame.width, height: headerView.calculateHeight(collectionView.frame.width))
            }
            return .zero
        } else {
            return .zero
        }
    }

in AssetsViewController

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