Code Monkey home page Code Monkey logo

Comments (4)

dan12411 avatar dan12411 commented on June 1, 2024 2

@ali0201
I tried to reset delegate for collectionView, it works! Thank you : )

    if #available(iOS 13.0, *) { } else {
      collectionView.delegate = nil
      if collectionView.delegate == nil {
        collectionView.delegate = self
      }
    }
    collectionView.setCollectionViewLayout(layout, animated: false)

from ibpcollectionviewcompositionallayout.

ali0201 avatar ali0201 commented on June 1, 2024 1

I found the solution.
You can try like this.

- (void)setViewModel:(GGViewModel *)viewModel {
    self.collectionView.dataSource = nil;
    self.collectionView.delegate = nil;

    if (!self.collectionView.dataSource) {
        self.collectionView.dataSource = self;
    }
    if (!self.collectionView.delegate) {
        self.collectionView.delegate = self;
    }
    [self.collectionView setCollectionViewLayout:layout animated:NO];
}

from ibpcollectionviewcompositionallayout.

ali0201 avatar ali0201 commented on June 1, 2024

I have a feature to switch layout ( grid <-> list), so I call setCollectionViewLayout to switch.
But if I start from 'grid -> list -> grid', it will crash.
From the call stack, we can see two IBPUICollectionViewCompositionalLayout is called repeatedly.

p.s. in iOS version below iOS 13.

Example code as follow,

    switch layoutMode {
    case .grid:
      collectionView.setCollectionViewLayout(grid, animated: false)
    case .list:
      collectionView.setCollectionViewLayout(list, animated: false)
    }

call stack & error message as follow,
截圖 2019-12-03 下午3 29 34

Hello, I also encountered this problem.

Have you solved it?

from ibpcollectionviewcompositionallayout.

dan12411 avatar dan12411 commented on June 1, 2024

@ali0201 not yet! I will give it a try, thank you!

from ibpcollectionviewcompositionallayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.