Giter Club home page Giter Club logo

Comments (6)

bhlvoong avatar bhlvoong commented on July 21, 2024

You can simply access your controller via cell.controller.

from lbtacomponents.

mallibabu442 avatar mallibabu442 commented on July 21, 2024

I've been unable to import the ClassName "LBTAComponents" from Pods. I was successfully installed the LBTAComponents through Pods,bt it can't.

from lbtacomponents.

dshukertjr avatar dshukertjr commented on July 21, 2024

I am having the same trouble as the person who opened this issue and I do not know why this issue is closed when the problem has not been solved.

How can I iterate through the cells and set the delegate?

from lbtacomponents.

dshukertjr avatar dshukertjr commented on July 21, 2024

So I solved this by implementing this

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> CustomCell {
        
        let cell: CustomCell
        
        if let cls = datasource?.cellClass(indexPath) {
            cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(cls), for: indexPath) as! DatasourceCell as! CustomCell
        } else if let cellClasses = datasource?.cellClasses(), cellClasses.count > indexPath.section {
            let cls = cellClasses[indexPath.section]
            cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(cls), for: indexPath) as! DatasourceCell as! CustomCell
        } else if let cls = datasource?.cellClasses().first {
            cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(cls), for: indexPath) as! DatasourceCell as! CustomCell
        } else {
            cell = collectionView.dequeueReusableCell(withReuseIdentifier: defaultCellId, for: indexPath) as! DatasourceCell as! CustomCell
        }
        
        cell.delegate = self
        
        cell.controller = self
        cell.datasourceItem = datasource?.item(indexPath)
        return cell
    }

into my DatasourceController. Basically it's a copy from the LBTA framework with the cell.delegate = self added to it.

from lbtacomponents.

bhlvoong avatar bhlvoong commented on July 21, 2024

As you can see, each cell has a "controller" property which you can use as your delegate.

from lbtacomponents.

dshukertjr avatar dshukertjr commented on July 21, 2024

Sorry, I am relatively new to swift programing, but how exactly do I set the controller property as my delegate? There is no function that iterates through each cells in LBTAComponents's DatasourceController, right?

from lbtacomponents.

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.