GithubHelp home page GithubHelp logo

Comments (8)

steipete avatar steipete commented on June 3, 2024

I'm not sure if it's possible to have different cell sizes - i hardly think so (but I'm not the author).
If you need to change the size, reloadData is probably the way to go.

from gmgridview.

malcommac avatar malcommac commented on June 3, 2024

Yeah you're right, that's a mistake of mine :)
Okay it could be a to-do feature :P

from gmgridview.

steipete avatar steipete commented on June 3, 2024

I believe the goals of this grid project are different - allowing custom-sized cells is a whole different bag of pain.
You can use same-sized cells and use different size within - so that the absolute border to the next cell is the same.

from gmgridview.

gmoledina avatar gmoledina commented on June 3, 2024

Yes the grid does not support different sizes per cell; it's just a grid.

Support for different sizes per orientation will be added soon though.

from gmgridview.

dxclancy avatar dxclancy commented on June 3, 2024

There are actually 2 ways to approach this. Assume ,for instance, that you want variable heights:

  1. A GMGridViewLayoutVerticalVariableHeightStrategy that has no access to the datasource.
  • it merely caches cell sizes as it produces them, based on previously seen sizes.
  • this is much more difficult, and requires more modification in the core code.
  • A theme of the changes in core revolve around being able to handle unbounded ranges or sizes, and then checking continuously as new origins are asked for to notice when the range or contentSize is now determined.
  • I have hacked together some stuff to do this, but it still suffers from content scrolls that are fast enough to not have asked for all previous cells when asking for a position origin. (since it will not have cached those position frames)
  • A VariableHeightLayoutStrategy that is constructed with access to the datasource. It can then maintain its own cache of cell sizes by asking the datasource directly. Less change is needed to the core code for this approach.
  • the major theme here, which is also needed in approach 1, is to have the core code act on and pass along the actual cell sizes, instead of the dataSource "size" which in this case is more of a maxSize.

Also, for this type of strategy, it is probably best to convert layout strategies to return NSIndexedSet instead of NSRange, as you may have to say that 0 - 45 is in bounds, but yet only half of those cells may be in bounds depending on how the heights stack up. Without this, your views and cache are bigger than they may need to be, which maybe isn't a big deal.

Note that i've only experimented with getting a layout and scrolling, not with any of the movement/editing/dragging/zooming etc...

from gmgridview.

dxclancy avatar dxclancy commented on June 3, 2024

http://i.imgur.com/l7rFv.jpg

from gmgridview.

gmoledina avatar gmoledina commented on June 3, 2024

Nice! One other way would be to have blocks in the layoutStrategy classes to compute the cellSizes. So the grid would set the block of the layout strategy and in it's implementation, call the datasource. The layout would just run the block to get the cellSize for each cell whenever needed; this way, the layout strategy doesn't know anything about the data source.

How are the cells aligned at the end of the scroll ?

from gmgridview.

dxclancy avatar dxclancy commented on June 3, 2024

I wasn't sure if you wanted the grid involved, so for now i just construct the strategy with a protocol that produces the sizes.

by aligned, do you mean visually at the bottom of the scroll? however they stack up. You can end up with a bunch of "jagged" white space. although i have an idea for how to make it look better.

from gmgridview.

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.