Comments (8)
The point of the optimization looks to be preventing unnecessary code running during scrolling. Rather than revert, it looks to me like the optimization code should check whether self.itemsSubviewsCacheIsValid as well. -reloadData and some of the insert/remove methods will invalidate the subview cache, whereas scrolling doesn't.
from gmgridview.
Thanks for the idea, @mwyman . Unfortunately, it looks like every time the optimization is taken, the subviews cache is valid as well.
from gmgridview.
Wouldn't you want to load the data of each cell separately ? What happens when you scroll otherwise ? You fetch the new data and then reload the grid ?
If you really need to do it this way, we could have a way to force-reloadData. But it seems that each cell data should be handled separately and so as soon as the data of a specific cell is available, only that cell gets reloaded.
from gmgridview.
The API I'm using returns data in pages with 24 items per page. In my
app, I display 12 cells per page. The items are basically image and
description.
When my grid delegate fetches a cell that hasn't yet been downloaded,
it triggers an async load of the data and returns an empty cell. I
have some synchronization which prevents this from happening multiple
times per page of data. When the API call returns, I call reloadData
so that all of the cells are created again.
I suppose the alternative you're suggesting is to go through and see
which of the new items have cells that are currently displayed and
reload those. Because that will be at least 1 page of cells and
potentially more depending on how fast the user scrolls, I've chosen
to reload the entire dataset.
Based on this use case, do you still recommend your suggestion or is
the "reload everything" approach worth supporting?
On Wed, Apr 11, 2012 at 4:39 AM, Gulam Moledina
[email protected]
wrote:
Wouldn't you want to load the data of each cell separately ? What happens when you scroll otherwise ? You fetch the new data and then reload the grid ?
If you really need to do it this way, we could have a way to force-reloadData. But it seems that each cell data should be handled separately and so as soon as the data of a specific cell is available, only that cell gets reloaded.
Reply to this email directly or view it on GitHub:
#65 (comment)
from gmgridview.
My app does a similar thing. The way I handle the async loading is to have the cell views associated with the asynchronous load operation, and the operation completes it sets whatever properties are necessary on the cell view, then calls -setNeedsDisplay on it. This way the views update, but don't require recalculating the grid layout.
If you have the cell views reference the asynchronous operation, you can also cancel the operation when the views get recycled in -GMGridView:cellForItemAtIndex:. This way you don't need to worry much about which views are onscreen, as that largely takes care of itself.
I have paged-loading grids with 24+ items onscreen at once, all loaded asynchronously (although often from cached data). The loading works fine, but without something preventing re-layout on every scroll, I get pretty laggy scrolling (particularly on iPad 1's).
My biggest concern when paging is the lack of a method similar to UITableView's -insertRowsAtIndexPaths:withRowAnimation:. Multiple -insertObjectAtIndex:... calls cause multiple re-layouts, or I have to call -reloadData, and I don't feel a clear sense of the expected behavior of the scroll content offset that results.
from gmgridview.
As explained by @mwyman, you can keep the reference to the cell.
Another approach would be to just keep the index of the cell and then call the cellForItemAtIndex: method (of the grid class, not talking about the delegate method) that will only return the cell if it hasn't been recycled.
I will add an example in the demo app eventually. You can create a new issue for the performance related concerns.
from gmgridview.
When you talk about datasource and loading, does this mean that you load the cells from a file?
If yes, would it be possible to include a sample of how to do that in the example project?
For a beginner like me it would be a great help.
from gmgridview.
Check whether use casting mechanism for view.Some time this is one of issue.
from gmgridview.
Related Issues (20)
- How can items drag in both the directions Left to Right and Right to Left ?
- GMGridView reloadData does not refresh view
- Archives has does not contain a single–bundle application or contains multiple products
- iOS 7 Horizontal strategy content size HOT 2
- No document about how to use this control
- if cell width is quite different, grid will show wrong cell when rotating
- ios 5.1 and lower issue HOT 1
- Grid cell want to draw from top HOT 1
- scrollToObjectAtIndex is not working properly when paging is enabled HOT 1
- memory problem - not released/reclaimed HOT 1
- another mem issue
- GMGrid Cell Alignment Issue
- Image stuck on screen
- Sort Help required!
- gridview.edit=yes,how to use sortingdelegate?
- index = -2147483648
- Maybe you can join a group function
- Button not working in subview GMGridviewCell
- Image link in README.md is broken
- animation repeat count doesn't work in GMGridViewCell
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmgridview.