Giter VIP home page Giter VIP logo

Comments (5)

PPacie avatar PPacie commented on June 19, 2024 1

Hi guys,

I could make the UITableView sections work without subclassing the UICollectionView nor adding new properties. Just used indexPath.section instead of indexPath.row in the tableView willDisplayCell: method:

tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.section)

PS: Of course you will also need to add the UITableView delegate methods to indicate the number of sections, title, etc.

Hope it helps, any doubts just let me know.

from collection-view-in-a-table-view-cell.

ashfurrow avatar ashfurrow commented on June 19, 2024

Great question! I did this once before, basically I just subclassed UICollectionView to add a property to store the index (before I used tag). You could use the same technique to store an index path instead, or use ObjC's associated objects, but I wouldn't recommend it 😉

Does that make sense?

from collection-view-in-a-table-view-cell.

dinhcuong1989 avatar dinhcuong1989 commented on June 19, 2024

i tried to get different Data for uicollectionView but it didn't work.

in TableView
tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.section)

in CollectionView
if (indexPath.section == 0) {
cell.titleItem.text = self.songName[indexPath.row]
}

    if (indexPath.section == 1) {
        cell.titleItem.text = self.songUrl[indexPath.row]
    }

it showed same text every section in tableView

from collection-view-in-a-table-view-cell.

PPacie avatar PPacie commented on June 19, 2024

In the collectionView you should have something like this:

cell.titleItem.text = self.songURL[collectionView.tag][indexPath.item]

I don't think you need to check for the indexPath.section == 1 there.

Hope it works for you.

from collection-view-in-a-table-view-cell.

mujtuba11khan avatar mujtuba11khan commented on June 19, 2024

Hi guys,

I could make the UITableView sections work without subclassing the UICollectionView nor adding new properties. Just used indexPath.section instead of indexPath.row in the tableView willDisplayCell: method:

tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.section)

PS: Of course you will also need to add the UITableView delegate methods to indicate the number of sections, title, etc.

Hope it helps, any doubts just let me know.

How did you used that table section then inside the collectionView method?

from collection-view-in-a-table-view-cell.

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.