Giter Club home page Giter Club logo

Comments (3)

ryanjm avatar ryanjm commented on June 7, 2024

I've added my own viewDidLoad function which is called manually. This seems to work pretty well so far.

from genericdatasource.

mohamede1945 avatar mohamede1945 commented on June 7, 2024

Ok. Generally, I always do the same thing like you did. Just add it in viewDidLoad. Because this is the correct place to do it in your situation, correct?. Now let's assume you have a UICollectionView and you want to you have a nested hierarchy of data sources. You want to select an the first cell of an inner data source which happened be the 3rd element in the 2nd section. You have 2 ways:

  1. Just use
collectionView.selectItemAtIndexPath(NSIndexPath(forItem: 2, inSection: 1), animated: false, scrollPosition: .Top)

But this one needs to know beforehand where is your cell. And if the data source hierarchies is changed, you have to update the code.

  1. You can use the data sources.
// you might create your data source hierarchies first.
...
// Make sure to have first. 
collectionView.ds_useDataSource(dataSource)
...

// then select the cell by using the data source this way.
innerDataSource.ds_reusableViewDelegate?.ds_selectItemAtIndexPath(NSIndexPath(forItem: 0, inSection: 0), animated: false, scrollPosition: .Top)

The advantage of second way is you don't need to know the global index path of your cell anymore.

from genericdatasource.

mohamede1945 avatar mohamede1945 commented on June 7, 2024

Please reopen if you more info.

from genericdatasource.

Related Issues (13)

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.